commit eeb95f5

Michael Forney  ·  2013-11-24 05:08:00 +0000 UTC
parent 5604e43
launch: Make error revoking input devices fatal

Since swc-launch allows you to specify the path to a display server, it
is important that input devices are revoked upon VT switch.

This change makes Linux-3.12 a requirement.
1 files changed,  +10, -14
+10, -14
 1@@ -72,6 +72,9 @@ static struct
 2     long console_mode;
 3 } original_vt_state;
 4 
 5+static void __attribute__((noreturn,format(printf,1,2)))
 6+    die(const char * format, ...);
 7+
 8 static void __attribute__((noreturn)) usage(const char * name)
 9 {
10     fprintf(stderr, "Usage: %s [-h] [--] <server> [server arguments...]\n", name);
11@@ -86,7 +89,7 @@ static void start_devices()
12         drmSetMaster(launcher.drm_fds[index]);
13 }
14 
15-static void stop_devices()
16+static void stop_devices(bool fatal)
17 {
18     unsigned index;
19 
20@@ -95,17 +98,10 @@ static void stop_devices()
21 
22     for (index = 0; index < launcher.num_input_fds; ++index)
23     {
24-        if (ioctl(launcher.input_fds[index], EVIOCREVOKE, 0) == -1
25-            && errno == EINVAL)
26+        if (ioctl(launcher.input_fds[index], EVIOCREVOKE, 0) == -1 && fatal)
27         {
28-            static bool warned = false;
29-
30-            if (!warned)
31-            {
32-                fprintf(stderr, "WARNING: Your kernel does not support EVIOCREVOKE; "
33-                                "input devices cannot be revoked\n");
34-                warned = true;
35-            }
36+            die("FATAL: Your kernel does not support EVIOCREVOKE; "
37+                "input devices cannot be revoked: %s\n", strerror(errno));
38         }
39         close(launcher.input_fds[index]);
40     }
41@@ -126,10 +122,10 @@ static void cleanup()
42         ioctl(launcher.tty_fd, VT_ACTIVATE, original_vt_state.vt);
43     }
44 
45-    stop_devices();
46+    stop_devices(false);
47 }
48 
49-static void __attribute__((noreturn,format(printf,1,2)))
50+void __attribute__((noreturn,format(printf,1,2)))
51     die(const char * format, ...)
52 {
53     va_list args;
54@@ -162,7 +158,7 @@ static void handle_chld(int signal)
55 
56 static void handle_usr1(int signal)
57 {
58-    stop_devices();
59+    stop_devices(true);
60     ioctl(launcher.tty_fd, VT_RELDISP, 1);
61 }
62