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
This commit is contained in:
Konstantin Belousov 2012-02-27 20:52:20 +00:00
parent 64ae02c365
commit 963a74f13c
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=232239

View File

@ -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 @@ char *argv[];
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; */
}