[net.unix-wizards] sleep problems

mike@whuxl.UUCP (BALDWIN) (03/16/85)

System V doesn't have the sleep(1) == sleep(INFIN) problem because it
uses setjmp/longjmp to catch the alarm:

sleep(amt)
{
	...
	signal(SIGALRM, catch);
	if (setjmp(buf) == 0) {
		alarm(amt);
		pause();
	}
	...
}

catch()
{
	longjmp(buf, 1);
}

So if the alarm comes in before the pause, it will skip over the pause.
Unfortunately, the longjmp causes a particularly bad thing to happen: if
another signal is caught while the sleep is pausing, and the alarm goes
off before the signal routine has returned, that signal routine will be
cut off in the middle!
							Michael Baldwin
							AT&T Bell Labs
							harpo!whuxl!mike