Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Posting-Version: notesfiles Path: utzoo!watmath!clyde!burl!ulysses!mhuxr!mhuxt!houxm!vax135!cornell!uw-beaver!tektronix!hplabs!hp-pcd!hpfcls!rml From: rml@hpfcls.UUCP (rml) Newsgroups: net.unix-wizards Subject: Re: Orphaned Response Message-ID: <132000009@hpfcls.UUCP> Date: Fri, 17-May-85 21:11:00 EDT Article-I.D.: hpfcls.132000009 Posted: Fri May 17 21:11:00 1985 Date-Received: Sun, 19-May-85 00:02:53 EDT References: <-40800@psivax.UUCP> Organization: Hewlett-Packard - Fort Collins, CO Lines: 22 Nf-ID: #R:psivax:-40800:hpfcls:132000009:37777777600:999 Nf-From: hpfcls!rml May 14 17:11:00 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