From owner-svn-src-all@FreeBSD.ORG Tue Apr 6 05:20:46 2010 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 8B27C106566B; Tue, 6 Apr 2010 05:20:46 +0000 (UTC) (envelope-from dougb@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 7A6868FC19; Tue, 6 Apr 2010 05:20:46 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id o365Kk6G056010; Tue, 6 Apr 2010 05:20:46 GMT (envelope-from dougb@svn.freebsd.org) Received: (from dougb@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id o365Kkpp056008; Tue, 6 Apr 2010 05:20:46 GMT (envelope-from dougb@svn.freebsd.org) Message-Id: <201004060520.o365Kkpp056008@svn.freebsd.org> From: Doug Barton Date: Tue, 6 Apr 2010 05:20:46 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r206248 - head/etc X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 06 Apr 2010 05:20:46 -0000 Author: dougb Date: Tue Apr 6 05:20:46 2010 New Revision: 206248 URL: http://svn.freebsd.org/changeset/base/206248 Log: In wait_for_pids(), pwait(1) can return when the process exits, but still exists as a zombie. The 'kill -0' test in this function can therefore return true even if the process isn't actually running. This could lead to wait_for_pids() printing an endless string of the pid number until the zombie finally exits. Solve this problem by moving the sleep up to after the 'kill -0' test, but only after we've run through the function once already. In the common case (only one pid in the list) this will always do the right thing. On the rare occasion that there is more than one pid in the list this will sleep 1 second per zombie process which will allow that process, and any other in the list a chance to exit. While I'm here, local'ize the variables that this function uses. Modified: head/etc/rc.subr Modified: head/etc/rc.subr ============================================================================== --- head/etc/rc.subr Tue Apr 6 05:13:04 2010 (r206247) +++ head/etc/rc.subr Tue Apr 6 05:20:46 2010 (r206248) @@ -355,6 +355,8 @@ _find_processes() # wait_for_pids() { + local _list _prefix _nlist _j + _list="$@" if [ -z "$_list" ]; then return @@ -365,6 +367,7 @@ wait_for_pids() for _j in $_list; do if kill -0 $_j 2>/dev/null; then _nlist="${_nlist}${_nlist:+ }$_j" + [ -n "$_prefix" ] && sleep 1 fi done if [ -z "$_nlist" ]; then @@ -373,7 +376,7 @@ wait_for_pids() _list=$_nlist echo -n ${_prefix:-"Waiting for PIDS: "}$_list _prefix=", " - pwait $_list 2>/dev/null || sleep 2 + pwait $_list 2>/dev/null done if [ -n "$_prefix" ]; then echo "."