summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorPeter Hutterer <peter.hutterer@who-t.net>2012-10-23 12:00:56 +1000
committerPeter Hutterer <peter.hutterer@who-t.net>2012-10-23 12:00:56 +1000
commitcfec5ff07d96bddbe031fd13586f9b2e4f303ea1 (patch)
tree86d1d26d5565156dbaf267d1f316b5ceb9ee9493 /src
parente2c8baf6e9124dab6d15258f1dd6d69b627ddde4 (diff)
parentd35d47be00c3b266df6b7bcda2e45ab74b3956f1 (diff)
Merge branch 'xlib-io-error-handler2'
Conflicts: test/xserver-test.cpp
Diffstat (limited to 'src')
-rw-r--r--src/xserver.cpp17
1 files changed, 17 insertions, 0 deletions
diff --git a/src/xserver.cpp b/src/xserver.cpp
index 9803e1f..55efab1 100644
--- a/src/xserver.cpp
+++ b/src/xserver.cpp
@@ -45,6 +45,7 @@
#include <fstream>
#include <X11/Xlib.h>
+#include <X11/Xlibint.h>
#include <X11/extensions/XInput2.h>
struct xorg::testing::XServer::Private {
@@ -396,6 +397,20 @@ const std::string& xorg::testing::XServer::GetVersion(void) {
return d_->version;
}
+static int _x_io_error_handler(Display *dpy)
+{
+ throw xorg::testing::XIOError("Connection to X Server lost. Possible server crash.");
+}
+
+void xorg::testing::XServer::RegisterXIOErrorHandler()
+{
+ XIOErrorHandler old_handler;
+ old_handler = XSetIOErrorHandler(_x_io_error_handler);
+
+ if (old_handler != _XDefaultIOError)
+ XSetIOErrorHandler(old_handler);
+}
+
void xorg::testing::XServer::Start(const std::string &program) {
TestStartup();
@@ -452,6 +467,8 @@ void xorg::testing::XServer::Start(const std::string &program) {
sigemptyset(&sig_mask);
sigaddset(&sig_mask, SIGCHLD);
sigprocmask(SIG_UNBLOCK, &sig_mask, NULL);
+
+ RegisterXIOErrorHandler();
}
bool xorg::testing::XServer::Terminate(unsigned int timeout) {