Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Posting-Version: version B 2.10.2 9/17/84; site godot.UUCP Path: utzoo!watmath!clyde!burl!ulysses!allegra!mit-eddie!godot!bruce From: bruce@godot.UUCP (Bruce Nemnich) Newsgroups: net.bugs.uucp Subject: Re: Re: hung line help needed Message-ID: <542@godot.UUCP> Date: Wed, 28-Nov-84 04:41:00 EST Article-I.D.: godot.542 Posted: Wed Nov 28 04:41:00 1984 Date-Received: Thu, 29-Nov-84 03:18:20 EST References: <85@daemon.UUCP> <33700001@trsvax.UUCP> <2923@allegra.UUCP> Reply-To: bruce@godot.UUCP (Bruce Nemnich) Organization: Thinking Machines, Cambridge, MA Lines: 48 Summary: In article <2923@allegra.UUCP> jpl@allegra.UUCP (John P. Linderman) writes: > >I think I can do better. Kirk Smith pointed out a bug in sleep(3) that >causes alarms to be masked off and never rearmed. Since uucico does >both sleeps and alarms, his fix (enclosed below) looks like it will cure >the disease whereas mine merely treated the symptoms. >.... > Description: > After a call to sleep(), the signal SIGALRM remains blocked. Gee, I thought we were on to something here, but.... > Repeat-By: > main() > { > sleep(1); > alarm(1); > } > This program will never terminate. Huh?? How could this not terminate? > > Fix: > In sleep.c add the following line to set the mask back to the old > mask before returning as follows: > > (void) sigvec(SIGALRM, &ovec, (struct sigvec *)0); > (void) setitimer(ITIMER_REAL, &oitv, (struct itimerval *)0); > +++ (void) sigsetmask(omask); > } > >John P. Linderman (Not alarmed by the slip in sleep) allegra!jpl The VAX 4.2bsd sleep(3) I have doesn't ever alter the signal mask, so it shouldn't need restoring. It uses sigpause() to make sure SIGALRM is allowed while it waits for the timer to go off; sigpause() restores the mask before returning. I actually blindly installed this "fix," but when it didn't help, I took a closer look at the code. Then I ran a bunch of tests on the original, and everything behaved as it should (SIGALRM is *not* blocked after a sleep()). Even if one longjmps out of a SIGALRM handler (during which SIGALRM is blocked), the mask is set back to its value at setjmp time by longjmp. -- --Bruce Nemnich, Thinking Machines Corporation, Cambridge, MA ihnp4!godot!bruce, bjn@mit-mc.arpa ... soon to be bruce@godot.arpa