Fix tdmtsak behaviour when tsak is restarted due to hardware changes

pull/2/head
Timothy Pearson 12 years ago
parent 789ab7d1f5
commit 864059732e

@ -157,8 +157,21 @@ int main (int argc, char *argv[])
} }
close(mPipe_fd); close(mPipe_fd);
// Now wait for SAK press // Now wait for SAK press
mPipe_fd = open(FIFO_FILE, O_RDONLY);
while (mPipe_fd > -1) { while (mPipe_fd > -1) {
mPipe_fd = open(FIFO_FILE, O_RDONLY);
if (mPipe_fd <= -1) {
// This may be a transient glitch, such as when a KVM is being toggled or a new keyboard has been added
// Wait up to 5 seconds while trying to open the pipe again
int timeout = 5;
while ((mPipe_fd <= -1) && (timeout > 0)) {
sleep(1);
mPipe_fd = open(FIFO_FILE, O_RDONLY);
timeout--;
}
}
if (mPipe_fd > -1) {
numread = read(mPipe_fd, readbuf, 6); numread = read(mPipe_fd, readbuf, 6);
readbuf[numread] = 0; readbuf[numread] = 0;
readbuf[127] = 0; readbuf[127] = 0;
@ -183,7 +196,9 @@ int main (int argc, char *argv[])
usleep(100); usleep(100);
} }
} }
close(mPipe_fd); close(mPipe_fd);
}
return 6; return 6;
} }
else { else {

Loading…
Cancel
Save