diff options
author | Carlos Garnacho <carlosg@gnome.org> | 2019-06-14 17:55:14 +0200 |
---|---|---|
committer | Carlos Garnacho <carlosg@gnome.org> | 2020-10-15 11:14:53 +0200 |
commit | 9f9c5365816bdd036fd80d54b22e86764ea4b7a7 (patch) | |
tree | fc1ed95b7455c5af6787219aef2c0b2acbdbfbac /src/XlibInt.c | |
parent | 4cb758019e374fa7c022fe79d28444e13441717b (diff) | |
download | xorg-lib-libX11-9f9c5365816bdd036fd80d54b22e86764ea4b7a7.tar.gz |
Add XSetIOErrorExitHandler() function
This function complements XSetIOErrorHandler(), allowing to override
the default behavior that trusts on I/O errors never coming back
(i.e. exit()ing the process).
This is meant as a mechanism for Wayland compositors (that are too
a X11 client + compositing manager) to unfasten seatbelts and jump
through the car window. It might get lucky and land on a stack of
pillows.
In consequence, some functions labeled as _X_NORETURN can as a
matter of fact return. So those hints were removed.
Signed-off-by: Carlos Garnacho <carlosg@gnome.org>
Reviewed-by: Michel Dänzer <mdaenzer@redhat.com>
Diffstat (limited to 'src/XlibInt.c')
-rw-r--r-- | src/XlibInt.c | 18 |
1 files changed, 16 insertions, 2 deletions
diff --git a/src/XlibInt.c b/src/XlibInt.c index 69e22a9d..a316dba3 100644 --- a/src/XlibInt.c +++ b/src/XlibInt.c @@ -1273,6 +1273,14 @@ SocketBytesReadable(Display *dpy) return bytes; } +_X_NORETURN void _XDefaultIOErrorExit( + Display *dpy, + void *user_data) +{ + exit(1); + /*NOTREACHED*/ +} + /* * _XDefaultIOError - Default fatal system error reporting routine. Called * when an X internal system error is encountered. @@ -1509,6 +1517,9 @@ int _XIOError ( Display *dpy) { + XIOErrorExitHandler exit_handler; + void *exit_handler_data; + dpy->flags |= XlibDisplayIOError; #ifdef WIN32 errno = WSAGetLastError(); @@ -1522,14 +1533,17 @@ _XIOError ( if (dpy->lock) (*dpy->lock->user_lock_display)(dpy); #endif + exit_handler = dpy->exit_handler; + exit_handler_data = dpy->exit_handler_data; UnlockDisplay(dpy); if (_XIOErrorFunction != NULL) (*_XIOErrorFunction)(dpy); else _XDefaultIOError(dpy); - exit (1); - /*NOTREACHED*/ + + exit_handler(dpy, exit_handler_data); + return 1; } |