Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP
Posting-Version: version B 2.10.2 11/03/84 (WLS Mods); site astrovax.UUCP
Path: utzoo!watmath!clyde!burl!ulysses!allegra!princeton!astrovax!wls
From: wls@astrovax.UUCP (William L. Sebok)
Newsgroups: net.bugs.uucp
Subject: Re: Re: hung line help needed
Message-ID: <500@astrovax.UUCP>
Date: Thu, 29-Nov-84 01:51:45 EST
Article-I.D.: astrovax.500
Posted: Thu Nov 29 01:51:45 1984
Date-Received: Fri, 30-Nov-84 04:45:49 EST
References: <85@daemon.UUCP> <33700001@trsvax.UUCP> <2923@allegra.UUCP> <542@godot.UUCP>
Organization: Princeton Univ. Astrophysics
Lines: 52

> 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?

I tried this myself and it terminated.  Then I tried inserting pause()
after the alarm(1).  The shell reported that the process had been killed
by an alarm signal.

> >
> >    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

> 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

For the record I installed this "fix" today myself and we hung again.
Load average at that time was about 13.  A pstat -p  showed that SIGALRM was
pending in the hung process.
-- 
Bill Sebok			Princeton University, Astrophysics
{allegra,akgua,burl,cbosgd,decvax,ihnp4,noao,princeton,vax135}!astrovax!wls