From 33721d7e579a4a4aef210f14eb240aff13ff4e3e Mon Sep 17 00:00:00 2001 From: albert <> Date: Thu, 6 Jan 2005 00:49:09 +0000 Subject: [PATCH] document #C to P change --- top.1 | 2 +- top.c | 8 +++++++- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/top.1 b/top.1 index 20505631..835bfca5 100644 --- a/top.1 +++ b/top.1 @@ -357,7 +357,7 @@ Zero in this field simply means priority will not be adjusted in determining a task's dispatchability. .TP 3 -j:\fB #C\fR \*(EM Last used \*(PU (SMP) +j:\fB P\fR \*(EM Last used \*(PU (SMP) A number representing the last used processor. In a true SMP environment this will likely change frequently since the kernel intentionally uses weak affinity. diff --git a/top.c b/top.c index e23fe2c8..65653394 100644 --- a/top.c +++ b/top.c @@ -3269,6 +3269,7 @@ int main (int dont_care_argc, char *argv[]) select(0, NULL, NULL, NULL, &tv); // ought to loop until done } else { long file_flags; + int rc; char c; fd_set fs; FD_ZERO(&fs); @@ -3276,8 +3277,13 @@ int main (int dont_care_argc, char *argv[]) file_flags = fcntl(STDIN_FILENO, F_GETFL); if(file_flags==-1) file_flags=0; fcntl(STDIN_FILENO, F_SETFL, O_NONBLOCK|file_flags); + // check 1st, in case tv zeroed (by sig handler) before it got set - if (chin(0, &c, 1) <= 0) { + 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 */ fcntl(STDIN_FILENO, F_SETFL, file_flags); select(1, &fs, NULL, NULL, &tv); fcntl(STDIN_FILENO, F_SETFL, O_NONBLOCK|file_flags);