Skip to content

Commit 22cff1f

Browse files
committed
rc.subr: Fix slow shutdown issue
Instead of sleeping after pwait returns, use its new -p option to obtain the list of processes that still have not terminated. MFC after: 3 days PR: 290357 Fixes: 5953e7c ("rc.subr: Move the sleep in wait_for_pids") Reviewed by: 0mp, markj Differential Revision: https://reviews.freebsd.org/D53294
1 parent 3d73146 commit 22cff1f

File tree

1 file changed

+8
-21
lines changed

1 file changed

+8
-21
lines changed

libexec/rc/rc.subr

Lines changed: 8 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -792,31 +792,18 @@ sort_lite()
792792
#
793793
wait_for_pids()
794794
{
795-
local _list _prefix _nlist _j
795+
local _list _prefix _j
796796

797-
_list="$@"
798-
if [ -z "$_list" ]; then
799-
return
800-
fi
801-
_prefix=
802-
while true; do
803-
_nlist=""
804-
for _j in $_list; do
805-
if kill -0 $_j 2>/dev/null; then
806-
_nlist="${_nlist}${_nlist:+ }$_j"
807-
fi
808-
done
809-
if [ -z "$_nlist" ]; then
810-
break
797+
for _j in "$@"; do
798+
if kill -0 $_j 2>/dev/null; then
799+
_list="${_list}${_list:+ }$_j"
811800
fi
812-
_list=$_nlist
801+
done
802+
_prefix=
803+
while [ -n "$_list" ]; do
813804
echo -n ${_prefix:-"Waiting for PIDS: "}$_list
814805
_prefix=", "
815-
pwait -o $_list 2>/dev/null
816-
# At least one of the processes we were waiting for
817-
# has terminated. Give init a chance to collect it
818-
# before looping around and checking again.
819-
sleep 1
806+
_list=$(pwait -op $_list 2>/dev/null)
820807
done
821808
if [ -n "$_prefix" ]; then
822809
echo "."

0 commit comments

Comments
 (0)