desktop: exit on EOF from stdin

This commit is contained in:
Andrew Tridgell 2011-11-09 16:15:28 +11:00
parent 3e5ec5d549
commit 4b50d2e639

View File

@ -52,13 +52,21 @@ int main(int argc, char * const argv[])
int fd_high = 0;
FD_ZERO(&fds);
FD_SET(0, &fds);
loop();
desktop_serial_select_setup(&fds, &fd_high);
tv.tv_sec = 0;
tv.tv_usec = 100;
select(fd_high+1, &fds, NULL, NULL, &tv);
if (select(fd_high+1, &fds, NULL, NULL, &tv) > 0 &&
FD_ISSET(0, &fds)) {
char c;
if (read(0, &c, 1) != 1) {
// EOF on stdin
exit(1);
}
}
}
return 0;
}