sleep problems

BALDWIN mike at whuxl.UUCP
Sat Mar 16 11:58:36 AEST 1985


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



More information about the Comp.unix.wizards mailing list