🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: gnu.emacs.bug
Article #98899

Bug in process-exit-status

#98899
From: Gillmer J. Derge
Date: Tue, 29 Jan 1991 21:18
54 lines
2842 bytes
	There is a bug in process-exit-status.  I will start off with
an explanation of the symptoms I have seen, and then follow with a
possible fix that appears to work for me.

Symptoms:
	The bug that I am getting is that process-exit-status returns
zero regardless of the actual exit status of the program.  For
example, if I interactively do the following:
-----------
(defvar test-process nil)
(setq test-process (start-process "xmenu" nil "xmenu" "-heading" "Test"
			"test1" "test2))
;; Wait until xmenu is finished
(process-exit-status test-process)
-----------
	I get 0, even though the program xmenu actually returns 101.
I am using both emacs version 18.55.7 and epoch 3.2 on a Sparcstation
1 with SunOS version 4.0.3c.  HAVE_PTYS is defined in my compilation.
	I have also tried various hacks using a process sentinel and
have not had any luck.

Fix?:
	I've done some digging into the source code, and it appears
that the cause of the problem is at the end of
wait_reading_process_input (process.c).  The following lines can be
found there:
-----------
/*
 * With ptys: when the parent process of a pty exits we are notified,
 * just as we would be with any of our other children.  After the process
 * exits, select() will indicate that we can read the channel.  When we
 * do this, read() returns 0.  Upon receiving this, we close the channel.
 *
 * For external channels, when the peer closes the connection, select()
 * will indicate that we can read the channel.  When we do this, read()
 * returns -1 with errno = ECONNRESET.  Since we never get notified of
 * this via wait3(), we must explictly mark the process as having exited.
 */
		  if ((XFASTINT (XPROCESS (proc)->flags) & PROC_STATUS)
		      == RUNNING)
		    {
		      XFASTINT (XPROCESS (proc)->flags) = EXITED | CHANGED;
		      XFASTINT (XPROCESS (proc)->reason) = 0;
		    }
-----------
	I have put debugging lines in the code, and determined that
the exit code is being set properly to 101, but it later gets stomped
on in this function.  At least in my situation, it appears that simply
removing the last line solves the problem, but, of course, this may
cause other problems of which I am not aware.

		Gill Derge
		derge@crd.ge.com
Technical Details
Message-ID: <9101292118.AA24422@paris.>
Path: arc1-ca.pugleaf.net!gmdzi!unido!mcsun!uunet!tut.cis.ohio-state.edu!paris.crd.ge.com!derge

Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit
X-Google-Thread: fb2f1,e757c18f8a87112a,start
X-Google-Attributes: gidfb2f1,public
X-Google-ArrivalTime: 1991-01-29 13:18:26 PST
Path: arc1-ca.pugleaf.net!gmdzi!unido!mcsun!uunet!tut.cis.ohio-state.edu!paris.crd.ge.com!derge
From: derge@paris.crd.ge.com (Gillmer J. Derge)
Newsgroups: gnu.emacs.bug
Subject: Bug in process-exit-status
Message-ID: <9101292118.AA24422@paris.>
Date: 29 Jan 91 21:18:26 GMT
Sender: news@tut.cis.ohio-state.edu
Distribution: gnu
Organization: GNUs Not Usenet
Lines: 54
Approved: bug-gnu-emacs@prep.ai.mit.edu