Orphaned Response

rml rml at hpfcls.UUCP
Sat May 18 11:11:00 AEST 1985


> 	I am having trouble in writing a routine to handle less than
> one second sleeps on BSD 4.2 using setitimer and sigpause. The routine
> I am using is similar to the code for sleep().  My problem, it keeps
> hanging sfter a random number of calls. It seems that eventually it
> does not return from sigpause. Why? What can I do about it?

The problem is that while the routine is using sigpause (instead of pause), 
it never masks out the SIGALRM signal, so it is subject to the standard
window of standard UN*X signals.  Specifically the signal can occur

                     here.
                      V
    while(wakeup == 0) sigpause(0);

Donn Seeley's posting in net.sources illustrates the use of sigblock to
eliminate this window.  From a quick look at the 4.2 source it has the
same problem as your routine (it does use sigblock, but not to solve
this problem).  I agree with Doug Gwyn that select provides the most
efficient short-term sleep.

			Bob Lenk
			{hplabs, ihnp4}!hpfcla!rml



More information about the Comp.unix.wizards mailing list