Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 27 Feb 2012 20:52:20 +0000 (UTC)
From:      Konstantin Belousov <kib@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r232239 - head/contrib/top
Message-ID:  <201202272052.q1RKqKnl036547@svn.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: kib
Date: Mon Feb 27 20:52:20 2012
New Revision: 232239
URL: http://svn.freebsd.org/changeset/base/232239

Log:
  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

Modified:
  head/contrib/top/top.c

Modified: head/contrib/top/top.c
==============================================================================
--- head/contrib/top/top.c	Mon Feb 27 19:05:01 2012	(r232238)
+++ head/contrib/top/top.c	Mon Feb 27 20:52:20 2012	(r232239)
@@ -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; */
-}
-



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201202272052.q1RKqKnl036547>