summaryrefslogtreecommitdiffstats
path: root/contrib/top/top.c
diff options
context:
space:
mode:
authorkib <kib@FreeBSD.org>2012-02-27 20:52:20 +0000
committerkib <kib@FreeBSD.org>2012-02-27 20:52:20 +0000
commit57e2f851ed8c3cd5f35ee1d8ab0edc357c7137f1 (patch)
tree2ee7259bcced44a7eba93f40420f4bad66b564ee /contrib/top/top.c
parent3ac0fcfb9762b2fd4991f32bff09543ba13df0d0 (diff)
downloadFreeBSD-src-57e2f851ed8c3cd5f35ee1d8ab0edc357c7137f1.zip
FreeBSD-src-57e2f851ed8c3cd5f35ee1d8ab0edc357c7137f1.tar.gz
Fix a race in top non-interactive mode. Use plain sleep(3) call instead
of arming timer and then pausing. If SIGALRM is delivered before pause(3) is entered, top hangs. Submitted by: Andrey Zonov <andrey zonov org> MFC after: 1 week
Diffstat (limited to 'contrib/top/top.c')
-rw-r--r--contrib/top/top.c16
1 files changed, 1 insertions, 15 deletions
diff --git a/contrib/top/top.c b/contrib/top/top.c
index e7e27d5..aaab027 100644
--- a/contrib/top/top.c
+++ b/contrib/top/top.c
@@ -70,7 +70,6 @@ int pcpu_stats = No;
/* signal handling routines */
sigret_t leave();
-sigret_t onalrm();
sigret_t tstop();
#ifdef SIGWINCH
sigret_t winch();
@@ -723,12 +722,7 @@ restart:
no_command = Yes;
if (!interactive)
{
- /* set up alarm */
- (void) signal(SIGALRM, onalrm);
- (void) alarm((unsigned)delay);
-
- /* wait for the rest of it .... */
- pause();
+ sleep(delay);
}
else while (no_command)
{
@@ -1174,11 +1168,3 @@ int status;
exit(status);
/*NOTREACHED*/
}
-
-sigret_t onalrm() /* SIGALRM handler */
-
-{
- /* this is only used in batch mode to break out of the pause() */
- /* return; */
-}
-
OpenPOWER on IntegriCloud