[GNOME-ABRT PATCH] Check if X display can be opened
Jakub Filak
jfilak at redhat.com
Fri Jul 19 15:01:45 UTC 2013
Gtk raise too general exception (RuntimeError) which should not be
caught and considered as evidence that X is accessible.
Closes rhbz#984315
Signed-off-by: Jakub Filak <jfilak at redhat.com>
---
src/gnome-abrt | 15 +++++++++++++++
1 file changed, 15 insertions(+)
diff --git a/src/gnome-abrt b/src/gnome-abrt
index b9be029..143de33 100755
--- a/src/gnome-abrt
+++ b/src/gnome-abrt
@@ -25,6 +25,21 @@ import signal
import traceback
from argparse import ArgumentParser
+from ctypes import cdll, util
+
+xlib_path = util.find_library('X11')
+if not xlib_path:
+ sys.stderr.write("Could not load X11 library\n")
+ sys.exit(1)
+
+xlib = cdll.LoadLibrary(xlib_path)
+display = xlib.XOpenDisplay(None)
+if display == 0:
+ sys.stderr.write("Cannot connect to X server\n")
+ sys.exit(2)
+
+xlib.XCloseDisplay(display)
+
# pygobject
#pylint: disable=E0611
from gi.repository import Gtk
--
1.8.3.1
More information about the Crash-catcher
mailing list