From 04b491c365e048e5a434bdcc2f686c425883f851 Mon Sep 17 00:00:00 2001 From: Lorenz Meier Date: Sat, 28 May 2016 13:40:14 +0200 Subject: [PATCH] Exit top on read failure --- src/systemcmds/top/top.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/systemcmds/top/top.c b/src/systemcmds/top/top.c index 68e2801bab..6de022e9a0 100644 --- a/src/systemcmds/top/top.c +++ b/src/systemcmds/top/top.c @@ -89,7 +89,11 @@ top_main(int argc, char *argv[]) if (ret > 0) { - read(0, &c, 1); + ret = read(0, &c, 1); + + if (ret) { + return 1; + } switch (c) { case 0x03: // ctrl-c