Subject: bug#10933: Acknowledgement (24.0.94; No output shown in *input/output* buffer of M-x gdb not working after first run)

From: Troels Nielsen <[email-masked]>
Date: Thu, 22 Mar 2012 10:30:32 +0100

Hi,

I think this bug is due to gdb-mi creating a pty which it expects to
remain open. When the process being debugged disconnects, emacs will
receive an EIO-errno and (I believe mistakenly) send a SIGCHLD to
itself, and stop listening to the pty.

This patch fixes the problem for me.

Troels
=== modified file 'src/process.c'
--- src/process.c	2012-01-21 10:54:19 +0000
+++ src/process.c	2012-03-21 22:16:02 +0000
@@ -4888,11 +4888,14 @@
 		 It can't hurt.  */
 	      else if (nread == -1 && errno == EIO)
 		{
-		  /* Clear the descriptor now, so we only raise the signal once.  */
-		  FD_CLR (channel, &input_wait_mask);
-		  FD_CLR (channel, &non_keyboard_wait_mask);
-
-		  kill (getpid (), SIGCHLD);
+                  /* Don't do anything if only a pty, with no associated process */
+                  if (XPROCESS(proc)->pid != -2) { 
+                    /* Clear the descriptor now, so we only raise the signal once.  */
+                    FD_CLR (channel, &input_wait_mask);
+                    FD_CLR (channel, &non_keyboard_wait_mask);
+                    
+                    kill (getpid (), SIGCHLD);
+                  }
 		}
 #endif /* HAVE_PTYS */
 	      /* If we can detect process termination, don't consider the process