Make tip exit if the device disappears, for instance when unplugging
or resetting USB serial devices. Somebody[tm] should rewrite tip(1) to use two thread instead of two processes or maybe even use that new-fangled "select(2)" or positively futuristic "poll(2)" system call.
This commit is contained in:
parent
1450485621
commit
a433ea32c0
@ -584,7 +584,7 @@ parwrite(int fd, char *buf, size_t n)
|
||||
bp++;
|
||||
}
|
||||
if (write(fd, buf, n) < 0) {
|
||||
if (errno == EIO)
|
||||
if (errno == EIO || errno == ENXIO)
|
||||
tipabort("Lost carrier.");
|
||||
/* this is questionable */
|
||||
perror("write");
|
||||
|
@ -148,11 +148,12 @@ tipout(void)
|
||||
scnt = read(FD, buf, BUFSIZ);
|
||||
if (scnt <= 0) {
|
||||
/* lost carrier */
|
||||
if (scnt == 0 || (scnt < 0 && errno == EIO)) {
|
||||
if (scnt == 0 ||
|
||||
(scnt < 0 && (errno == EIO || errno == ENXIO))) {
|
||||
sigemptyset(&mask);
|
||||
sigaddset(&mask, SIGTERM);
|
||||
sigprocmask(SIG_BLOCK, &mask, NULL);
|
||||
intTERM(0);
|
||||
intTERM(SIGHUP);
|
||||
/*NOTREACHED*/
|
||||
}
|
||||
continue;
|
||||
|
Loading…
Reference in New Issue
Block a user