fix(top): stop when the input can't be polled (#29227)

This commit is contained in:
Benjamin Cabé authored and GitHub committed 2026-10-16 15:43:00 +02:00
1 parent 4d7e4de777
commit 33109cd71d
1 file changed
+6
+6
View File
@@ -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);