diff src/process.c @ 5588:2dbefd79b3d3

Prevent SIGPIPEs in deactivate_process(). * process.c (deactivate_process): Use Lstream_close_noflush on output pipe instead of Lstream_close. * lstream.c (Lstream_close_noflush): New. Factored out of Lstream_close. (Lstream_close): Use Lstream_close_noflush. * lstream.h (Lstream_close_noflush): Declare it.
author Stephen J. Turnbull <stephen@xemacs.org>
date Sat, 29 Oct 2011 01:10:32 +0900
parents 56144c8593a8
children 3192994c49ca
line wrap: on
line diff
--- a/src/process.c	Sat Oct 29 00:35:33 2011 +0900
+++ b/src/process.c	Sat Oct 29 01:10:32 2011 +0900
@@ -2150,8 +2150,20 @@
   /* Must call this before setting the streams to nil */
   event_stream_unselect_process (p, 1, 1);
 
+  /* We can get here in case of a crash in the external process, and then
+     the Lstream_close on output will cause a SIGPIPE, which we're not ready
+     for here.  It looks to me like all cases where this function is called
+     we know the process has exited (but I'm not 100% sure for the call in
+     execute_internal_event (event-stream.c)), so it should be OK to use
+     Lstream_close_noflush.
+
+     #### The layering here needs a rethink.  We should just be able
+     to call Lstream_close, and let the Lstream's implementation decide
+     if it can flush safely or not.  The immediate problem is that the
+     Lstream needs to know the process's status, but I don't think it has
+     a handle to the process. */
   if (!NILP (DATA_OUTSTREAM (p)))
-    Lstream_close (XLSTREAM (DATA_OUTSTREAM (p)));
+    Lstream_close_noflush (XLSTREAM (DATA_OUTSTREAM (p)));
   if (!NILP (DATA_INSTREAM (p)))
     Lstream_close (XLSTREAM (DATA_INSTREAM (p)));
   if (!NILP (DATA_ERRSTREAM (p)))