summaryrefslogtreecommitdiff
path: root/usr.bin/top/top.c
diff options
context:
space:
mode:
authorOtto Moerbeek <otto@cvs.openbsd.org>2006-03-04 06:54:19 +0000
committerOtto Moerbeek <otto@cvs.openbsd.org>2006-03-04 06:54:19 +0000
commitfd62d65e5f8853059be1e74a932d8ab0c43cb2ca (patch)
treedeb3ab4aac823824e76318f15b59e24061520a28 /usr.bin/top/top.c
parent2f6b75939571c8eda00d4473203ef29575b9ac20 (diff)
Handle signals in non-interactive mode. "looks good" deraadt@
Diffstat (limited to 'usr.bin/top/top.c')
-rw-r--r--usr.bin/top/top.c17
1 files changed, 12 insertions, 5 deletions
diff --git a/usr.bin/top/top.c b/usr.bin/top/top.c
index 39db4594a3b..3ebe661bba1 100644
--- a/usr.bin/top/top.c
+++ b/usr.bin/top/top.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: top.c,v 1.41 2005/12/04 23:10:06 tedu Exp $ */
+/* $OpenBSD: top.c,v 1.42 2006/03/04 06:54:18 otto Exp $ */
/*
* Top users/processes display for Unix
@@ -499,6 +499,15 @@ restart:
/* wait for the rest of it .... */
pause();
+ if (leaveflag)
+ exit(0);
+ if (tstopflag) {
+ (void) signal(SIGTSTP, SIG_DFL);
+ (void) kill(0, SIGTSTP);
+ /* reset the signal handler */
+ (void) signal(SIGTSTP, tstop);
+ tstopflag = 0;
+ }
} else {
while (no_command)
if (rundisplay())
@@ -536,10 +545,8 @@ rundisplay(void)
pfd[0].fd = STDIN_FILENO;
pfd[0].events = POLLIN;
- if (leaveflag) {
- end_screen();
- exit(0);
- }
+ if (leaveflag)
+ quit(0);
if (tstopflag) {
/* move to the lower left */
end_screen();