From cf7cf622046b0e1a2817e1da4aa8bc6f513b0153 Mon Sep 17 00:00:00 2001 From: Denis Vlasenko Date: Wed, 19 Mar 2008 19:38:46 +0000 Subject: *: s/BB_SIGS_FATAL/BB_FATAL_SIGS/ (latter proved easier to remember) top: fix "top stack; #endif } - } + } /* end of "while we read /proc" */ if (ntop == 0) { - bb_error_msg_and_die("no process info in /proc"); + bb_error_msg("no process info in /proc"); + break; } if (scan_mask == TOP_MASK) { @@ -875,9 +878,14 @@ int top_main(int argc ATTRIBUTE_UNUSED, char **argv) #if !ENABLE_FEATURE_USE_TERMIOS sleep(interval); #else - if (safe_poll(pfd, 1, interval * 1000) > 0) { - if (read(0, &c, 1) != 1) /* signal */ - break; + if (option_mask32 & (OPT_b|OPT_EOF)) + /* batch mode, or EOF on stdin ("top 0) { + if (safe_read(0, &c, 1) != 1) { /* error/EOF? */ + option_mask32 |= OPT_EOF; + continue; + } if (c == initial_settings.c_cc[VINTR]) break; c |= 0x20; /* lowercase */ @@ -922,7 +930,9 @@ int top_main(int argc ATTRIBUTE_UNUSED, char **argv) #endif } #endif /* FEATURE_USE_TERMIOS */ - } + } /* end of "while (1)" */ + bb_putchar('\n'); + reset_term(); return EXIT_SUCCESS; } -- cgit v1.1