diff options
author | peter <peter@FreeBSD.org> | 1997-05-18 10:57:49 +0000 |
---|---|---|
committer | peter <peter@FreeBSD.org> | 1997-05-18 10:57:49 +0000 |
commit | 9e3a2a0c2bba75d9444fb16eabbc328c7938dbbe (patch) | |
tree | d5a8e9914bd8711a8581122eb1df1456ba3b7c21 /lib/libc/gen/usleep.c | |
parent | 8fc601bf6f37fba71b0dcd292805572648a02312 (diff) | |
download | FreeBSD-src-9e3a2a0c2bba75d9444fb16eabbc328c7938dbbe.zip FreeBSD-src-9e3a2a0c2bba75d9444fb16eabbc328c7938dbbe.tar.gz |
Update the nanosleep versions to set a SIGALRM handler while sleeping.
This appears to appease Apache, although depending on having sleep(3)
changing the SIGALRM handler is a bit bogus.
Diffstat (limited to 'lib/libc/gen/usleep.c')
-rw-r--r-- | lib/libc/gen/usleep.c | 10 |
1 files changed, 9 insertions, 1 deletions
diff --git a/lib/libc/gen/usleep.c b/lib/libc/gen/usleep.c index 1549173..0f3e004 100644 --- a/lib/libc/gen/usleep.c +++ b/lib/libc/gen/usleep.c @@ -46,18 +46,22 @@ static char sccsid[] = "@(#)usleep.c 8.1 (Berkeley) 6/4/93"; #if !defined(_THREAD_SAFE) && !defined(USE_NANOSLEEP) #define TICK 10000 /* system clock resolution in microseconds */ #define USPS 1000000 /* number of microseconds in a second */ +#endif #define setvec(vec, a) \ vec.sv_handler = a; vec.sv_mask = vec.sv_onstack = 0 +#if !defined(_THREAD_SAFE) && !defined(USE_NANOSLEEP) static int ringring; +#endif static void sleephandler() { +#if !defined(_THREAD_SAFE) && !defined(USE_NANOSLEEP) ringring = 1; -} #endif +} void @@ -67,15 +71,19 @@ usleep(useconds) #if defined(_THREAD_SAFE) || defined(USE_NANOSLEEP) struct timespec time_to_sleep; struct timespec time_remaining; + struct sigvec vec, ovec; if (useconds) { time_to_sleep.tv_nsec = (useconds % 1000000) * 1000; time_to_sleep.tv_sec = useconds / 1000000; + setvec(vec, sleephandler); + (void) sigvec(SIGALRM, &vec, &ovec); do { nanosleep(&time_to_sleep, &time_remaining); time_to_sleep = time_remaining; } while (time_to_sleep.tv_sec != 0 && time_to_sleep.tv_nsec != 0); + (void) sigvec(SIGALRM, &ovec, (struct sigvec *)0); } #else register struct itimerval *itp; |