Core files

Currently, GDK calls g_error() ( => abort() ) for
X IO errors and X errors.

For X IO errors, this makes no sense, since 
an X IO errors almost certainly have no relation
to anything the client does. They are going to
occur either because the server died, or becuase
somebody did an XKillClient.

So, for X IO errors, I'm about to apply the
following patch which makes GDK die nicely
in that case.

The question is what to do about X errors. On
one hand, they typically do indicate something
going wrong, but on the other hand:

 1) They occur asynchronously in general, so a
    core isn't very useful unless the program
    was run with --sync

 2) They may occur for unpredictable reasons
    (i.e., the plug part of a plug/socket dies
    at the wrong time)

 3) Enlightment does the wrong thing when you
    Annihilate a window and destroys the window
    instead of XKillClient()'ing the window.
    So this currently causes GTK+ to core dump.

So, I'd like to make the core-dumping not the
default. Given that, there are two options
 a) Never dump core, always exit() with a error
    on stdout.

 b) Dump core only if GTK+ is compiled with


--- gtk+-1.2.3/gdk/gdk.c.nocore	Mon May 10 22:31:07 1999
+++ gtk+-1.2.3/gdk/gdk.c	Tue Jun  8 12:14:55 1999
@@ -31,6 +31,7 @@
 #include <stdlib.h>
 #include <string.h>
 #include <limits.h>
+#include <errno.h>
 #include <sys/select.h>
@@ -1074,8 +1075,27 @@
 static int
 gdk_x_io_error (Display *display)
-  g_error ("an x io error occurred");
-  return 0;
+  /* This is basically modelled after the code in XLib. We need
+   * an explicit error handler here, so we can disable our atexit()
+   * which would otherwise cause a nice segfault.
+   * We fprintf(stderr, instead of g_warning() because g_warning()
+   * could possibly be redirected to a dialog
+   */
+  if (errno == EPIPE)
+    {
+      fprintf (stderr, "X connection to %s broken (explicit kill or server shutdown).\n", gdk_display ? DisplayString (gdk_display) : gdk_get_display());
+    }
+  else
+    {
+      fprintf (stderr, "Fatal IO error %d (%s) on X server %s.\n",
+	       errno, g_strerror (errno),
+	       gdk_display ? DisplayString (gdk_display) : gdk_get_display());
+    }
+  /* Disable the atexit shutdown for GDK */
+  gdk_initialized = 0;
+  exit(1);
 gchar *

[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]