From owner-svn-src-stable@FreeBSD.ORG Tue Mar 6 11:16:14 2012 Return-Path: Delivered-To: svn-src-stable@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id B07991065673; Tue, 6 Mar 2012 11:16:14 +0000 (UTC) (envelope-from kib@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 9AF9F8FC21; Tue, 6 Mar 2012 11:16:14 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.4/8.14.4) with ESMTP id q26BGE98037001; Tue, 6 Mar 2012 11:16:14 GMT (envelope-from kib@svn.freebsd.org) Received: (from kib@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id q26BGE8n036999; Tue, 6 Mar 2012 11:16:14 GMT (envelope-from kib@svn.freebsd.org) Message-Id: <201203061116.q26BGE8n036999@svn.freebsd.org> From: Konstantin Belousov Date: Tue, 6 Mar 2012 11:16:14 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-8@freebsd.org X-SVN-Group: stable-8 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r232599 - stable/8/contrib/top X-BeenThere: svn-src-stable@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for all the -stable branches of the src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 06 Mar 2012 11:16:14 -0000 Author: kib Date: Tue Mar 6 11:16:14 2012 New Revision: 232599 URL: http://svn.freebsd.org/changeset/base/232599 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/8/contrib/top/top.c Directory Properties: stable/8/contrib/top/ (props changed) Modified: stable/8/contrib/top/top.c ============================================================================== --- stable/8/contrib/top/top.c Tue Mar 6 11:05:50 2012 (r232598) +++ stable/8/contrib/top/top.c Tue Mar 6 11:16:14 2012 (r232599) @@ -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; */ -} -