diff options
| author | Andrey A. Chernov <ache@FreeBSD.org> | 1997-08-12 19:54:31 +0000 | 
|---|---|---|
| committer | Andrey A. Chernov <ache@FreeBSD.org> | 1997-08-12 19:54:31 +0000 | 
| commit | fc0cc5ad9b6c922f79c3cdec58c18a03f713c2be (patch) | |
| tree | e9668fa9e7311c055f1ef2a6bd031069ded52153 /lib/libc/gen | |
| parent | b39d66c04ae615a15974e620682b4abddb7b6661 (diff) | |
Notes
Diffstat (limited to 'lib/libc/gen')
| -rw-r--r-- | lib/libc/gen/sleep.c | 39 | 
1 files changed, 20 insertions, 19 deletions
diff --git a/lib/libc/gen/sleep.c b/lib/libc/gen/sleep.c index d142a83f1d28..34057413ddd0 100644 --- a/lib/libc/gen/sleep.c +++ b/lib/libc/gen/sleep.c @@ -100,19 +100,6 @@ sleep(seconds)  	int alarm_blocked;  	if (seconds != 0) { -	again: -		/* -		 * XXX -		 * Hack to work around itimerfix(9) gratuitously limiting -		 * the acceptable range for a struct timeval.tv_sec to -		 * <= ITIMERMAX -		 */ -		if (seconds > ITIMERMAX) { -			rest = seconds - ITIMERMAX; -			seconds = ITIMERMAX; -		} -		time_to_sleep.tv_sec = seconds; -		time_to_sleep.tv_nsec = 0;  		/* Block SIGALRM while fiddling with it */  		sigemptyset(&mask); @@ -132,6 +119,20 @@ sleep(seconds)  			sigaction(SIGALRM, &act, &oact);  		} +	again: +		/* +		 * XXX +		 * Hack to work around itimerfix(9) gratuitously limiting +		 * the acceptable range for a struct timeval.tv_sec to +		 * <= ITIMERMAX +		 */ +		if (seconds > ITIMERMAX) { +			rest = seconds - ITIMERMAX; +			seconds = ITIMERMAX; +		} +		time_to_sleep.tv_sec = seconds; +		time_to_sleep.tv_nsec = 0; +    		/*    		 * signanosleep() uses the given mask for the lifetime of    		 * the syscall only - it resets on return.  Note that the @@ -142,12 +143,6 @@ sleep(seconds)    		 */  		signanosleep(&time_to_sleep, &time_remaining, &omask); -		if (!alarm_blocked) { -			/* Unwind */ -			sigaction(SIGALRM, &oact, (struct sigaction *)0); -			sigprocmask(SIG_SETMASK, &omask, (sigset_t *)0); -		} -  		if (rest != 0 &&  		    time_remaining.tv_sec == 0 &&  		    time_remaining.tv_nsec == 0) { @@ -156,6 +151,12 @@ sleep(seconds)  			goto again;  		} +		if (!alarm_blocked) { +			/* Unwind */ +			sigaction(SIGALRM, &oact, (struct sigaction *)0); +			sigprocmask(SIG_SETMASK, &omask, (sigset_t *)0); +		} +  		/* return how long is left */  		rest += time_remaining.tv_sec;  		if (time_remaining.tv_nsec > 0)  | 
