diff --git a/tsak/main.cpp b/tsak/main.cpp index e49c05147..2cac66a3a 100644 --- a/tsak/main.cpp +++ b/tsak/main.cpp @@ -34,6 +34,7 @@ License along with tsak. If not, see http://www.gnu.org/licenses/. #include #include #include +#include #include #include extern "C" { @@ -72,6 +73,9 @@ int keyboard_fds[MAX_KEYBOARDS]; int child_pids[MAX_KEYBOARDS]; int child_led_pids[MAX_KEYBOARDS]; +int current_keyboard = -1; +int devout[MAX_KEYBOARDS]; + const char *keycode[256] = { "", "", "1", "2", "3", "4", "5", "6", "7", "8", @@ -119,6 +123,15 @@ void signal_callback_handler(int signum) void tsak_friendly_termination() { int i; + if ((current_keyboard >= 0) && (devout[current_keyboard] > 0)) { + if (ioctl(devout[current_keyboard],UI_DEV_DESTROY)<0) { + fprintf(stderr, "[tsak] Unable to destroy input device with UI_DEV_DESTROY\n"); + } + else { + fprintf(stderr, "[tsak] Device destroyed\n"); + } + } + // Close down all child processes for (i=0; i0) { + // Terminate parent + controlpipe.active = false; + return 0; + } + } + while (1) { if (depcheck == false) { controlpipe.active = true; @@ -566,7 +602,7 @@ int main (int argc, char *argv[]) for (current_keyboard=0;current_keyboard0) { - // Terminate parent - controlpipe.active = false; - return 0; - } - // Close all keyboard file descriptors; we don't need them in this process and they can end up dangling/locked during forced restart for (int current_keyboard=0;current_keyboard