From c13a48e74ec89eafa9b529a87253a631ef02f2e2 Mon Sep 17 00:00:00 2001 From: Jeremy Huddleston Date: Mon, 10 Oct 2011 12:09:39 -0700 Subject: [PATCH] Xnest: Remove socket and its lock file on exit https://bugs.freedesktop.org/show_bug.cgi?id=11484 Signed-off-by: Jeremy Huddleston Reviewed-by: Mikhail Gusarov --- hw/xnest/Display.c | 15 ++++++++++++++- hw/xnest/Events.c | 2 ++ 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/hw/xnest/Display.c b/hw/xnest/Display.c index b78aff597..7acad755c 100644 --- a/hw/xnest/Display.c +++ b/hw/xnest/Display.c @@ -17,6 +17,9 @@ is" without express or implied warranty. #include #endif +#include +#include + #include #include #include "screenint.h" @@ -52,6 +55,14 @@ Pixmap xnestScreenSaverPixmap; XlibGC xnestBitmapGC; unsigned long xnestEventMask; +static int _X_NORETURN +x_io_error_handler (Display *dpy) { + ErrorF("Lost connection to X server: %s\n", strerror(errno)); + CloseWellKnownConnections(); + OsCleanup(1); + exit(1); +} + void xnestOpenDisplay(int argc, char *argv[]) { @@ -60,7 +71,9 @@ xnestOpenDisplay(int argc, char *argv[]) int i, j; if (!xnestDoFullGeneration) return; - + + XSetIOErrorHandler(x_io_error_handler); + xnestCloseDisplay(); xnestDisplay = XOpenDisplay(xnestDisplayName); diff --git a/hw/xnest/Events.c b/hw/xnest/Events.c index 619427ded..2399313c6 100644 --- a/hw/xnest/Events.c +++ b/hw/xnest/Events.c @@ -198,6 +198,8 @@ xnestCollectEvents(void) case DestroyNotify: if (xnestParentWindow != (Window) 0 && X.xdestroywindow.window == xnestParentWindow) + CloseWellKnownConnections(); + OsCleanup(1); exit (0); break;