Description: Check for stdin eof if term Author: Samuel Thibault Bug-Debian: http://bugs.debian.org/458986 Reviewed-by: Craig Small Index: b/top.c =================================================================== --- a/top.c 2009-11-24 21:00:34.000000000 +1100 +++ b/top.c 2009-11-24 21:00:35.000000000 +1100 @@ -3408,9 +3408,8 @@ // check 1st, in case tv zeroed (by sig handler) before it got set rc = chin(0, &c, 1); if (rc <= 0) { - // EOF is pretty much a "can't happen" except for a kernel bug. - // We should quickly die via SIGHUP, and thus not spin here. - // if (rc == 0) end_pgm(0); /* EOF from terminal */ + if (rc == 0) end_pgm(0); /* EOF from terminal, may happen if top + * erroneously gets detached from it. */ fcntl(STDIN_FILENO, F_SETFL, file_flags); select(1, &fs, NULL, NULL, &tv); fcntl(STDIN_FILENO, F_SETFL, O_NONBLOCK|file_flags);