🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: gnu.emacs.bug
Article #98311

broken network connection makes Emacs loop forever (e.g. NNTP + GNUS)

#98311
From: Paul Eggert
Date: Sat, 12 Oct 1991 00:14
67 lines
3129 bytes
When a network server exits, GNU Emacs 18.57 goes into a loop reading zero
bytes from the socket to the exited server.  For example, if GNUS is reading
from an NNTP server that abruptly dies, GNU Emacs will chew up CPU time in a
loop that reads 0 bytes from the corresponding socket.  This is on a Sun
Sparcstation 1 running SunOS 4.1.1.

I suspect that this bug stems from the change described as follows in
src/ChangeLog:

	Thu Aug 23 16:41:11 1990  Richard Stallman  (rms at mole.ai.mit.edu)

		* process.c (wait_reading_process_output):
		Don't deactivate process for eof if SIGCHLD is defined.
		That used to mask the proper exit status.

But the code in question ignores EOF not only for child processes, but also
for network connections, which never issue SIGCHLD signals.

Here is a patch.  This patch causes wait_reading_process_input to not ignore a
zero value returned from read_process_output if the corresponding process
object is a network connection.

Even with this patch, Emacs theoretically can busily wait (reading 0 bytes in
a loop) from the time it reads 0 bytes from a dying child to the time it
receives the corresponding SIGCHLD.  I haven't observed this behavior in
practice, though.

===================================================================
RCS file: process.c,v
retrieving revision 18.57
diff -c -r18.57 process.c
*** 18.57	1991/01/16 01:28:48
--- process.c	1991/10/11 22:31:06
***************
*** 1732,1738 ****
  		 available now and a closed pipe.
  		 With luck, a closed pipe will be accompanied by
  		 subprocess termination and SIGCHLD.  */
! 	      else if (nread == 0)
  		;
  #endif /* O_NDELAY */
  #endif /* O_NONBLOCK */
--- 1732,1738 ----
  		 available now and a closed pipe.
  		 With luck, a closed pipe will be accompanied by
  		 subprocess termination and SIGCHLD.  */
! 	      else if (nread == 0 && ! NETCONN_P (proc))
  		;
  #endif /* O_NDELAY */
  #endif /* O_NONBLOCK */
***************
*** 1751,1757 ****
  /* If we can detect process termination, don't consider the process
     gone just because its pipe is closed.  */
  #ifdef SIGCHLD
! 	      else if (nread == 0)
  		;
  #endif
  	      else
--- 1751,1757 ----
  /* If we can detect process termination, don't consider the process
     gone just because its pipe is closed.  */
  #ifdef SIGCHLD
! 	      else if (nread == 0 && ! NETCONN_P (proc))
  		;
  #endif
  	      else
Technical Details
Message-ID: <9110120014.AA00906@ata.twinsun.com>
Path: arc1-ca.pugleaf.net!gmdzi!unido!fauern!Sirius.dfn.de!darwin.sura.net!udel!wupost!zaphod.mps.ohio-state.edu!cis.ohio-state.edu!twinsun.COM!eggert

Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit
X-Google-Thread: fb2f1,d9f3f5964378328e,start
X-Google-Attributes: gidfb2f1,public
X-Google-ArrivalTime: 1991-10-11 17:14:22 PST
Path: arc1-ca.pugleaf.net!gmdzi!unido!fauern!Sirius.dfn.de!darwin.sura.net!udel!wupost!zaphod.mps.ohio-state.edu!cis.ohio-state.edu!twinsun.COM!eggert
From: eggert@twinsun.COM (Paul Eggert)
Newsgroups: gnu.emacs.bug
Subject: broken network connection makes Emacs loop forever (e.g. NNTP + GNUS)
Message-ID: <9110120014.AA00906@ata.twinsun.com>
Date: 12 Oct 91 00:14:22 GMT
Sender: gnulists@ai.mit.edu
Distribution: gnu
Organization: GNUs Not Usenet
Lines: 67
Approved: bug-gnu-emacs@prep.ai.mit.edu