From f268c17fb1210cc0fc649d42c3c6622add2e1dd6 Mon Sep 17 00:00:00 2001 From: Simon Ser Date: Mon, 31 Aug 2020 19:29:33 +0200 Subject: [PATCH] Setup an X IO error handler The default erro handler calls exit(), which doesn't work well when multiple threads are involved. Closes: https://github.com/Plagman/gamescope/issues/46 --- src/steamcompmgr.cpp | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/steamcompmgr.cpp b/src/steamcompmgr.cpp index 1904ccd..bc91144 100644 --- a/src/steamcompmgr.cpp +++ b/src/steamcompmgr.cpp @@ -2233,6 +2233,13 @@ error (Display *dpy, XErrorEvent *ev) return 0; } +static int +handle_io_error(Display *dpy) +{ + fprintf(stderr, "X11 I/O error\n"); + pthread_exit(NULL); +} + static Bool register_cm (Display *dpy) { @@ -2503,6 +2510,7 @@ steamcompmgr_main (int argc, char **argv) exit (1); } XSetErrorHandler (error); + XSetIOErrorHandler (handle_io_error); if (synchronize) XSynchronize (dpy, 1); scr = DefaultScreen (dpy);