From 33109cd71d9f8c2a052d34ded54ca48dffcfe1ed Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Benjamin=20Cab=C3=A9?= Date: Fri, 16 Oct 2026 15:43:00 +0200 Subject: [PATCH] fix(top): stop when the input can't be polled (#29227) --- src/systemcmds/top/top.cpp | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/systemcmds/top/top.cpp b/src/systemcmds/top/top.cpp index a2b364f0aa1..22a4de56783 100644 --- a/src/systemcmds/top/top.cpp +++ b/src/systemcmds/top/top.cpp @@ -95,6 +95,12 @@ extern "C" __EXPORT int top_main(int argc, char *argv[]) fds.events = POLLIN; ret = poll(&fds, 1, 0); + if ((ret < 0) || (fds.revents & POLLNVAL)) { + // no input to stop on, as from a shell without a terminal + cpuload_monitor_stop(); + return 0; + } + if (ret > 0) { ret = read(0, &c, 1);