aboutsummaryrefslogtreecommitdiff
path: root/etc
diff options
context:
space:
mode:
authorDoug Barton <dougb@FreeBSD.org>2010-04-06 05:20:46 +0000
committerDoug Barton <dougb@FreeBSD.org>2010-04-06 05:20:46 +0000
commita6f9d19c1eee8ff21872e34f96b35fc155dd921c (patch)
tree171cae2e526f97b3669f6e6f8dda9975616870be /etc
parent83d90bb1dd6fcd8f5fe26e61d52dfd0173eeee67 (diff)
downloadsrc-a6f9d19c1eee8ff21872e34f96b35fc155dd921c.tar.gz
src-a6f9d19c1eee8ff21872e34f96b35fc155dd921c.zip
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.
Notes
Notes: svn path=/head/; revision=206248
Diffstat (limited to 'etc')
-rw-r--r--etc/rc.subr5
1 files changed, 4 insertions, 1 deletions
diff --git a/etc/rc.subr b/etc/rc.subr
index 0c28f2d267aa..18273be83abb 100644
--- a/etc/rc.subr
+++ b/etc/rc.subr
@@ -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 "."