swc

Unnamed repository; edit this file 'description' to name the repository.
git clone git://git.nihaljere.xyz/swc
Log | Files | Refs | README | LICENSE

commit eeb95f5d0c302670f849795f546685b60bd9d722
parent 5604e437f46af3d1b5d14f48f70d15c1a1df1b24
Author: Michael Forney <mforney@mforney.org>
Date:   Sat, 23 Nov 2013 21:08:00 -0800

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.

Diffstat:
Mlaunch/launch.c | 24++++++++++--------------
1 file changed, 10 insertions(+), 14 deletions(-)

diff --git a/launch/launch.c b/launch/launch.c @@ -72,6 +72,9 @@ static struct long console_mode; } original_vt_state; +static void __attribute__((noreturn,format(printf,1,2))) + die(const char * format, ...); + static void __attribute__((noreturn)) usage(const char * name) { fprintf(stderr, "Usage: %s [-h] [--] <server> [server arguments...]\n", name); @@ -86,7 +89,7 @@ static void start_devices() drmSetMaster(launcher.drm_fds[index]); } -static void stop_devices() +static void stop_devices(bool fatal) { unsigned index; @@ -95,17 +98,10 @@ static void stop_devices() for (index = 0; index < launcher.num_input_fds; ++index) { - if (ioctl(launcher.input_fds[index], EVIOCREVOKE, 0) == -1 - && errno == EINVAL) + if (ioctl(launcher.input_fds[index], EVIOCREVOKE, 0) == -1 && fatal) { - static bool warned = false; - - if (!warned) - { - fprintf(stderr, "WARNING: Your kernel does not support EVIOCREVOKE; " - "input devices cannot be revoked\n"); - warned = true; - } + die("FATAL: Your kernel does not support EVIOCREVOKE; " + "input devices cannot be revoked: %s\n", strerror(errno)); } close(launcher.input_fds[index]); } @@ -126,10 +122,10 @@ static void cleanup() ioctl(launcher.tty_fd, VT_ACTIVATE, original_vt_state.vt); } - stop_devices(); + stop_devices(false); } -static void __attribute__((noreturn,format(printf,1,2))) +void __attribute__((noreturn,format(printf,1,2))) die(const char * format, ...) { va_list args; @@ -162,7 +158,7 @@ static void handle_chld(int signal) static void handle_usr1(int signal) { - stop_devices(); + stop_devices(true); ioctl(launcher.tty_fd, VT_RELDISP, 1); }