提交 4469bd7b 编写于 作者: W Willy Tarreau 提交者: Stefan Roese

tools: kwboot: properly quit when read() returns 0

When kwboot is attached to a terminal which disappears such as one
connected via an unplugged USB cable, read() returns 0, making kwboot
loop until a key is pressed in the terminal. The only case where read()
may return 0 here is when the terminal is closed anyway, so let's
properly handle this one and report is similar to other errors.
Signed-off-by: NWilly Tarreau <w@1wt.eu>
Signed-off-by: NStefan Roese <sr@denx.de>
上级 3475a71d
......@@ -182,7 +182,7 @@ kwboot_tty_recv(int fd, void *buf, size_t len, int timeo)
}
n = read(fd, buf, len);
if (n < 0)
if (n <= 0)
goto out;
buf = (char *)buf + n;
......@@ -466,7 +466,7 @@ kwboot_term_pipe(int in, int out, char *quit, int *s)
char _buf[128], *buf = _buf;
nin = read(in, buf, sizeof(buf));
if (nin < 0)
if (nin <= 0)
return -1;
if (quit) {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册