diff src/device-x.c @ 167:85ec50267440 r20-3b10

Import from CVS: tag r20-3b10
author cvs
date Mon, 13 Aug 2007 09:45:46 +0200
parents 5a88923fcbfe
children 15872534500d
line wrap: on
line diff
--- a/src/device-x.c	Mon Aug 13 09:44:44 2007 +0200
+++ b/src/device-x.c	Mon Aug 13 09:45:46 2007 +0200
@@ -55,6 +55,9 @@
 Lisp_Object Qx_error; 
 Lisp_Object Qinit_pre_x_win, Qinit_post_x_win;
 
+/* $B@ZJ"(B, n.  Japanese ritual suicide. */
+int x_seppuku_on_epipe;
+
 /* The application class of Emacs. */
 Lisp_Object Vx_emacs_application_class;
 
@@ -650,6 +653,19 @@
   if (d)
     enqueue_magic_eval_event (io_error_delete_device, dev);
 
+  /* CvE, July 16, 1996, XEmacs 19.14 */
+  /* Test for broken pipe error, which indicates X-server has gone down */
+  if (errno == EPIPE && x_seppuku_on_epipe)
+    {
+      /* Most probably X-server has gone down: Avoid infinite loop by just */
+      /* exiting */
+      /* slb:  This sounds really, really dangerous to do by default, so */
+      /* I'm adding a guard to avoid doing this as default behavior */
+      stderr_out( "\n\nXEmacs exiting on broken pipe (errno %d, %s)\n",
+		  errno, strerror(errno));
+      exit(errno);
+    }
+
   return 0;
 }
 
@@ -1438,6 +1454,14 @@
 */ );
   Vx_initial_argv_list = Qnil;
 
+  DEFVAR_BOOL ("x-seppuku-on-epipe", &x_seppuku_on_epipe /*
+When non-nil terminate XEmacs immediately on SIGPIPE from the X server.
+XEmacs doesn't terminate properly on some systems.
+When this variable is non-nil, XEmacs will commit immediate suicide
+when it gets a sigpipe from the X Server.
+*/ );
+  x_seppuku_on_epipe = 0;
+
   Fprovide (Qx);
 
   staticpro (&Vdefault_x_device);