changeset 36623:9fde2182c68a

(Fset_process_filter): Don't crash if the input file descriptor of PROCESS is closed. (Fset_process_window_size): Likewise.
author Gerd Moellmann <gerd@gnu.org>
date Wed, 07 Mar 2001 12:55:01 +0000
parents 22c3a86a20ee
children d8ad1534920a
files src/process.c
diffstat 1 files changed, 29 insertions(+), 11 deletions(-) [+]
line wrap: on
line diff
--- a/src/process.c	Wed Mar 07 10:19:33 2001 +0000
+++ b/src/process.c	Wed Mar 07 12:55:01 2001 +0000
@@ -734,18 +734,34 @@
   (process, filter)
      register Lisp_Object process, filter;
 {
+  struct Lisp_Process *p;
+  
   CHECK_PROCESS (process, 0);
-  if (EQ (filter, Qt))
+  p = XPROCESS (process);
+
+  /* Don't signal an error if the process' input file descriptor
+     is closed.  This could make debugging Lisp more difficult,
+     for example when doing something like
+
+     (setq process (start-process ...))
+     (debug)
+     (set-process-filter process ...)  */
+  
+  if (XINT (p->infd) >= 0)
     {
-      FD_CLR (XINT (XPROCESS (process)->infd), &input_wait_mask);
-      FD_CLR (XINT (XPROCESS (process)->infd), &non_keyboard_wait_mask);
+      if (EQ (filter, Qt))
+	{
+	  FD_CLR (XINT (p->infd), &input_wait_mask);
+	  FD_CLR (XINT (p->infd), &non_keyboard_wait_mask);
+	}
+      else if (EQ (XPROCESS (process)->filter, Qt))
+	{
+	  FD_SET (XINT (p->infd), &input_wait_mask);
+	  FD_SET (XINT (p->infd), &non_keyboard_wait_mask);
+	}
     }
-  else if (EQ (XPROCESS (process)->filter, Qt))
-    {
-      FD_SET (XINT (XPROCESS (process)->infd), &input_wait_mask);
-      FD_SET (XINT (XPROCESS (process)->infd), &non_keyboard_wait_mask);
-    }
-  XPROCESS (process)->filter = filter;
+  
+  p->filter = filter;
   return filter;
 }
 
@@ -793,8 +809,10 @@
   CHECK_PROCESS (process, 0);
   CHECK_NATNUM (height, 0);
   CHECK_NATNUM (width, 0);
-  if (set_window_size (XINT (XPROCESS (process)->infd),
-		       XINT (height), XINT (width)) <= 0)
+  
+  if (XINT (XPROCESS (process)->infd < 0)
+      || set_window_size (XINT (XPROCESS (process)->infd),
+			  XINT (height), XINT (width)) <= 0)
     return Qnil;
   else
     return Qt;