1
commit 24dc214f55e7c7c17d888d0ccf94cd3625767462
2
Author: Michael Biebl <biebl@debian.org>
3
Date: Mon Sep 20 00:45:16 2010 +0200
5
linux: Check for VT_WAITEVENT ioctl during runtime
7
Since 2782cc8d4950effbc4407455e72bd4750cef6e11 ConsoleKit fails, if it
8
has been compiled on a linux kernel >= 2.6.32 but is run with an older
9
kernel. Check for VT_WAITEVENT ioctl during runtime and fallback to the
10
old behaviour of creating a thread for every possible vt.
12
diff --git a/src/ck-vt-monitor.c b/src/ck-vt-monitor.c
13
index 369c63e..9310341 100644
14
--- a/src/ck-vt-monitor.c
15
+++ b/src/ck-vt-monitor.c
20
+#include <sys/ioctl.h>
23
#include <glib/gi18n.h>
24
@@ -311,6 +312,34 @@ schedule_process_queue (CkVtMonitor *vt_monitor)
25
G_UNLOCK (schedule_lock);
30
+vt_waitevent_supported (int fd)
32
+ static int supported = -1;
38
+ res = ioctl(fd, VT_WAITEVENT, NULL);
41
+ if (errno == EINVAL) {
42
+ g_debug ("VT_WAITEVENT not supported on this system");
45
+ } else if (errno == EFAULT) {
46
+ g_debug ("VT_WAITEVENT supported on this system");
51
+ g_debug ("Unexpected result for VT_WAITEVENT check, returning FALSE");
57
vt_thread_start (ThreadData *data)
59
@@ -322,6 +351,9 @@ vt_thread_start (ThreadData *data)
63
+ if (!vt_waitevent_supported(vt_monitor->priv->vfd))
67
res = ck_wait_for_console_switch (vt_monitor->priv->vfd, &num);
69
@@ -340,7 +372,10 @@ vt_thread_start (ThreadData *data)
70
schedule_process_queue (vt_monitor);
78
res = ck_wait_for_active_console_num (vt_monitor->priv->vfd, num);
80
/* FIXME: what do we do if it fails? */
81
@@ -357,8 +392,8 @@ vt_thread_start (ThreadData *data)
82
/* schedule processing of queue */
83
schedule_process_queue (vt_monitor);
89
if (vt_monitor->priv->vt_thread_hash != NULL) {
90
g_hash_table_remove (vt_monitor->priv->vt_thread_hash, GUINT_TO_POINTER (num));
91
@@ -418,19 +453,24 @@ vt_add_watches (CkVtMonitor *vt_monitor)
92
sigaction (SIGPOLL, &act, NULL);
94
ioctl (vt_monitor->priv->vfd, I_SETSIG, S_MSG);
95
-#elif defined (VT_WAITEVENT)
102
+#if defined (VT_WAITEVENT)
103
+ if (!vt_waitevent_supported(vt_monitor->priv->vfd))
107
id = GINT_TO_POINTER (1);
108
if (g_hash_table_lookup (vt_monitor->priv->vt_thread_hash, id) == NULL)
109
vt_add_watch_unlocked (vt_monitor, 1);
110
- G_UNLOCK (hash_lock);
112
- guint max_consoles;
114
- gint32 current_num;
121
current_num = vt_monitor->priv->active_num;
122
@@ -442,7 +482,6 @@ vt_add_watches (CkVtMonitor *vt_monitor)
125
for (i = 1; i < max_consoles; i++) {
128
/* don't wait on the active vc */
129
if (i == current_num) {
130
@@ -457,6 +496,7 @@ vt_add_watches (CkVtMonitor *vt_monitor)
135
G_UNLOCK (hash_lock);