Subject: usleep and signals
To: None <current-users@NetBSD.ORG>
From: Rick Byers <>
List: current-users
Date: 08/18/1997 03:36:56
I'm working on a program that will receive an alarm signal once a second.
It needs to sleep for a period of time.  How can I do this in a way that
is compatable with both -current and 1.2.1?  Using nanosleep (with a loop
to watch for the signal) works great under current, but nanosleep doesn't
exist under 1.2.1.  usleep works under 1.2.1, but doesn't return how much
time is left to sleep when a signal hits it (and the signal doesn't get
handled - unlike nanosleep).

Is there any easy way around this?  I'm thinking I'll have to resort to
turning off my alarm before the usleep, and turning it back on afterwards.
The only problem with this is that it doesn't get processed during the
sleep.  I guess I could make a loop of 1 second usleeps (or sleeps for
that matter), and call the handler inside the loop.  I assume nanosleep
was put in to avoid this kludge ?


Rick Byers                                      Internet Access Worldwide                                System Admin, Tech Support
Welland, Ontario, Canada                                    (905)714-1400