These patches make `top' not busy-loop (chewing up CPU) if the pty it is on is closed, and make it default to using all of the lines of the window, both initially and after resizing. Index: display.c =================================================================== diff -u -r1.1 -r1.2 --- display.c 1998/08/28 21:27:17 1.1 +++ display.c 1999/04/19 18:33:32 1.2 @@ -29,6 +29,7 @@ #include "os.h" #include #include +#include #include "screen.h" /* interface to screen package */ #include "layout.h" /* defines for screen position layout */ @@ -837,12 +838,13 @@ register char ch; register char cnt = 0; register char maxcnt = 0; + int n; /* allow room for null terminator */ size -= 1; /* read loop */ - while ((fflush(stdout), read(0, ptr, 1) > 0)) + while ((fflush(stdout), (n = read(0, ptr, 1)) > 0)) { /* newline means we are done */ if (((ch = *ptr) == '\r') || (ch == '\n')) @@ -898,6 +900,9 @@ } } } + + if (n == 0 || (n < 0 && errno == EIO)) + exit(0); /* all done -- null terminate the string */ *ptr = '\0'; Index: top.c =================================================================== diff -u -r1.1 -r1.2 --- top.c 1998/08/28 21:27:17 1.1 +++ top.c 1999/04/19 18:33:32 1.2 @@ -127,6 +127,7 @@ int (*d_header)() = i_header; int (*d_process)() = i_process; +int topn = Default_TOPN; main(argc, argv) @@ -145,7 +146,6 @@ static char tempbuf1[50]; static char tempbuf2[50]; int old_sigmask; /* only used for BSD-style signals */ - int topn = Default_TOPN; int delay = Default_DELAY; int displays = 0; /* indicates unspecified */ time_t curr_time; @@ -967,7 +967,7 @@ get_screensize(); /* tell display to resize */ - max_topn = display_resize(); + topn = max_topn = display_resize(); /* reset the signal handler */ (void) signal(SIGWINCH, winch); Index: top.local.h =================================================================== diff -u -r1.1 -r1.2 --- top.local.h 1998/08/28 21:27:17 1.1 +++ top.local.h 1999/04/19 18:33:32 1.2 @@ -43,7 +43,7 @@ #endif #ifndef Default_TOPN -#define Default_TOPN 15 +#define Default_TOPN Infinity #endif #ifndef Default_DELAY