summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlan Coopersmith <alan.coopersmith@oracle.com>2013-03-30 23:22:32 -0700
committerAlan Coopersmith <alan.coopersmith@oracle.com>2013-04-27 19:13:10 -0700
commite1e0fb6a9894ec0b11cf6fcdfa37a14071aad24d (patch)
treefbedf67ee84e7f485c99a87ff21ac94d5eec1cb6
parent174f2a057e6e202a8c66f6ecd230ed77ee81e10d (diff)
Install custom XIOError handler to abort on IO error
Allows debugging the core file to see what went wrong Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com>
-rw-r--r--src/xlib_client.c15
1 files changed, 15 insertions, 0 deletions
diff --git a/src/xlib_client.c b/src/xlib_client.c
index a612910..80bd66a 100644
--- a/src/xlib_client.c
+++ b/src/xlib_client.c
@@ -29,14 +29,29 @@
#include <X11/Xlibint.h>
#include <assert.h>
#include <sys/types.h>
+#include <stdio.h>
+#include <errno.h>
static pid_t server_pid;
+static int
+XhivIOError(Display *dpy) {
+ fprintf(stderr, "XIO: fatal IO error %d (%s) on X server \"%s\"\r\n",
+ errno, strerror (errno), DisplayString (dpy));
+ fprintf (stderr,
+ " after %lu requests (%lu known processed) with %d events remaining.\r\n",
+ NextRequest(dpy) - 1, LastKnownRequestProcessed(dpy),
+ QLength(dpy));
+ abort();
+}
+
Display *
XhivOpenDisplay(xhiv_response *responses) {
char *dpyname;
Display *dpy;
+ XSetIOErrorHandler(XhivIOError);
+
dpyname = XhivOpenServer(responses, &server_pid);
assert(dpyname != NULL);