svn commit: r232543 - stable/9/contrib/top

Konstantin Belousov kib at FreeBSD.org
Mon Mar 5 11:45:20 UTC 2012


Author: kib
Date: Mon Mar  5 11:45:19 2012
New Revision: 232543
URL: http://svn.freebsd.org/changeset/base/232543

Log:
  MFC r232239:
  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.

Modified:
  stable/9/contrib/top/top.c
Directory Properties:
  stable/9/contrib/top/   (props changed)

Modified: stable/9/contrib/top/top.c
==============================================================================
--- stable/9/contrib/top/top.c	Mon Mar  5 11:43:27 2012	(r232542)
+++ stable/9/contrib/top/top.c	Mon Mar  5 11:45:19 2012	(r232543)
@@ -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; */
-}
-


More information about the svn-src-stable-9 mailing list