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
This commit is contained in:
Simon Ser 2020-08-31 19:29:33 +02:00 committed by Pierre-Loup A. Griffais
parent 9d6b37ee22
commit f268c17fb1

View file

@ -2233,6 +2233,13 @@ error (Display *dpy, XErrorEvent *ev)
return 0; return 0;
} }
static int
handle_io_error(Display *dpy)
{
fprintf(stderr, "X11 I/O error\n");
pthread_exit(NULL);
}
static Bool static Bool
register_cm (Display *dpy) register_cm (Display *dpy)
{ {
@ -2503,6 +2510,7 @@ steamcompmgr_main (int argc, char **argv)
exit (1); exit (1);
} }
XSetErrorHandler (error); XSetErrorHandler (error);
XSetIOErrorHandler (handle_io_error);
if (synchronize) if (synchronize)
XSynchronize (dpy, 1); XSynchronize (dpy, 1);
scr = DefaultScreen (dpy); scr = DefaultScreen (dpy);