From 9e080e8aa5c219b4f621afa4730914e265fa5848 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Yannic=20Schr=C3=B6der?= Date: Tue, 20 Sep 2016 14:16:40 +0200 Subject: [PATCH] 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. --- tools/sky/serialdump.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/tools/sky/serialdump.c b/tools/sky/serialdump.c index deab56df4..7cc0d0e1e 100644 --- a/tools/sky/serialdump.c +++ b/tools/sky/serialdump.c @@ -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) {