Terminate serialdump when serial device disconnects

The running serialdump does not recover from a disconnected device but
runs indefinitely with outputting anything. This makes it quit with a
proper error message.
This commit is contained in:
Yannic Schröder 2016-09-20 14:16:40 +02:00
parent 2974b796d1
commit 9e080e8aa5
1 changed files with 5 additions and 0 deletions

View File

@ -281,6 +281,11 @@ main(int argc, char **argv)
perror("could not read");
exit(-1);
}
if(n == 0) {
errno = EBADF;
perror("serial device disconnected");
exit(-1);
}
for(i = 0; i < n; i++) {
switch(mode) {