[comp.bugs.4bsd] inetd gaffe

chris@mimsy.UUCP (08/27/87)

	Index:	etc/inetd.c 4.3BSD Fix

Description:
	Inetd has a classic asynchronous programming error that could
	make it `miss' a SIGHUP signal.

Repeat-By:
	Unlikely.  Read the code instead.

Fix:
	The extra `if' cuts down on syscall overhead, since nsock==0 is
	rare.

RCS file: RCS/inetd.c,v
retrieving revision 1.1
retrieving revision 1.2
diff -c2 -r1.1 -r1.2
*** /tmp/,RCSt1007856	Thu Aug 27 04:03:51 1987
--- /tmp/,RCSt2007856	Thu Aug 27 04:03:53 1987
***************
*** 211,216 ****
  	    fd_set readable;
  
! 	    while (nsock == 0)
  		    sigpause(0);
  	    readable = allsock;
  	    if ((n = select(maxsock + 1, &readable, (fd_set *)0,
--- 211,220 ----
  	    fd_set readable;
  
! 	    if (nsock == 0) {
! 		(void) sigblock(SIGBLOCK);
! 		while (nsock == 0)
  		    sigpause(0);
+ 		(void) sigsetmask(0);
+ 	    }
  	    readable = allsock;
  	    if ((n = select(maxsock + 1, &readable, (fd_set *)0,
-- 
In-Real-Life: Chris Torek, Univ of MD Comp Sci Dept (+1 301 454 7690)
Domain:	chris@mimsy.umd.edu	Path:	seismo!mimsy!chris