summaryrefslogtreecommitdiffstats
path: root/tsak
diff options
context:
space:
mode:
authorTimothy Pearson <kb9vqf@pearsoncomputing.net>2013-07-25 14:10:22 -0500
committerTimothy Pearson <kb9vqf@pearsoncomputing.net>2013-07-25 14:10:22 -0500
commitf449d57ba7d97ded6e00cb45edd5a827a5fa8870 (patch)
tree4142d928808666749f6a7dd0663e557976a42caf /tsak
parentc060a817e492351d3097b9d84f80c9b17690342a (diff)
downloadtdebase-f449d57ba7d97ded6e00cb45edd5a827a5fa8870.tar.gz
tdebase-f449d57ba7d97ded6e00cb45edd5a827a5fa8870.zip
Fix a few tsak glitches on hotplug
Diffstat (limited to 'tsak')
-rw-r--r--tsak/main.cpp24
1 files changed, 10 insertions, 14 deletions
diff --git a/tsak/main.cpp b/tsak/main.cpp
index 8fa36f4ab..e49c05147 100644
--- a/tsak/main.cpp
+++ b/tsak/main.cpp
@@ -334,7 +334,7 @@ bool setupPipe()
bool setupLockingPipe(bool writepid)
{
- /* Create the FIFOs if they do not exist */
+ /* Create the FIFOs as they may not exist */
umask(0);
mkdir(FIFO_DIR,0644);
@@ -385,17 +385,6 @@ void restart_tsak()
}
}
- // Wait for process termination
- sleep(1);
-
- // Release all exclusive keyboard locks
- for (int current_keyboard=0;current_keyboard<keyboard_fd_num;current_keyboard++) {
- if(ioctl(keyboard_fds[current_keyboard], EVIOCGRAB, 0) < 0) {
- fprintf(stderr, "[tsak] Failed to release exclusive input device lock\n");
- }
- close(keyboard_fds[current_keyboard]);
- }
-
// Unset the exclusive file lock
if (mPipe_fd_out != -1) {
struct flock fl;
@@ -647,7 +636,7 @@ int main (int argc, char *argv[])
while (1) {
if ((rd = read(keyboard_fds[current_keyboard], ev, size)) < size) {
fprintf(stderr, "[tsak] Read failed.\n");
- break;
+ return 13;
}
if (ev[0].value == 0 && ev[0].type == 1) { // Read the key release event
@@ -699,13 +688,20 @@ int main (int argc, char *argv[])
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<keyboard_fd_num;current_keyboard++) {
+ close(keyboard_fds[current_keyboard]);
+ keyboard_fds[current_keyboard] = 0;
+ }
+ keyboard_fd_num = 0;
+
// Prevent multiple process instances from starting
setupLockingPipe(true);
// Wait a little bit so that udev hotplug can stabilize before we start monitoring
sleep(1);
- fprintf(stderr, "[tsak] Hotplug monitoring process started\n");
+ fprintf(stderr, "[tsak] Hotplug monitoring process started (%ld)\n", getpid());
// Monitor for hotplugged keyboards
int j;