Subject: bug#14297: 24.3.50; emacs subprocesses don't exit on "exit"

From: Paul Eggert <[email-masked]>
Date: Mon, 13 May 2013 09:58:17 -0700

On 05/13/13 08:59, Eli Zaretskii wrote:
> So I'm not sure this is the same problem.

I agree.  I brought up the issue because the question
arose as to how (process-live-p proc) is connected to
the window toolkit.

It's conceivable, for example, that a buggy Gtk plugin
is doing a waitpid (-1, ...), which would mess up
Emacs greatly (and would also mess up other applications,
the symptoms observed here).

Perhaps we should apply something like the following patch,
to help detect these situations better?

=== modified file 'src/sysdep.c'
--- src/sysdep.c	2013-03-24 12:59:45 +0000
+++ src/sysdep.c	2013-05-13 16:56:59 +0000
@@ -315,7 +315,8 @@ get_child_status (pid_t child, int *stat
 void
 wait_for_termination (pid_t child, int *status, bool interruptible)
 {
-  get_child_status (child, status, 0, interruptible);
+  if (get_child_status (child, status, 0, interruptible) < 0)
+    emacs_abort ();
 }
 
 /* Report whether the subprocess with process id CHILD has changed status.
@@ -330,7 +331,10 @@ wait_for_termination (pid_t child, int *
 pid_t
 child_status_changed (pid_t child, int *status, int options)
 {
-  return get_child_status (child, status, WNOHANG | options, 0);
+  pid_t p = get_child_status (child, status, WNOHANG | options, 0);
+  if (p < 0)
+    emacs_abort ();
+  return p;
 }
 
 /*