Trouble killing processes in SysV/AT

Guy Harris guy at gorodish.Sun.COM
Mon May 2 07:37:45 AEST 1988


> >If the sleep priority is above PZERO, the [signalled] sleep() will return
> >an error corresponding to "I was interrupted!".
> 
> Unless Sun has made some big kernel changes recently, this is not the
> case.  See /sys/sys/kern_synch.c, at the label `psig' in sleep().

OK - from the 3.5 version of "kern_synch.c":

	psig:
		if (pri & PCATCH)
			return (1);
		longjmp(&u.u_qsave);
		/*NOTREACHED*/

Sun - or, more correctly, AT&T - made a small kernel change a while ago.  (AT&T
made it either in S5"R1" or S5R2 - I don't have the S5R[12] sources online
anymore to check precisely when this was done; Sun picked up AT&T's change in
SunOS 3.2.)  If the priority field to "sleep" has PCATCH (0400) ORed into it,
"sleep" won't "longjmp" if a signal interrupts the sleep, but will return 1.
Under any circumstances, it will return 0 if the sleep terminates normally.

> Returning an error from sleep would be a viable alternative to `catch'
> and `throw' routines, although it would entail more work.

The PCATCH bit is required to evoke the new behavior from "sleep", thus
reducing the amount of work needed to have "sleep" return an error.  Old
drivers, etc. don't have to be changed except to cast the result of "sleep" to
"void" (yes, we "lint" our kernels before we ship them - "lint"ing kernels has
caught a number of bugs before compiling).



More information about the Comp.unix.wizards mailing list