Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/etc * change wait_for_pids() to spin forever (rather than ju...



details:   https://anonhg.NetBSD.org/src/rev/eb0660d07f0d
branches:  trunk
changeset: 509641:eb0660d07f0d
user:      lukem <lukem%NetBSD.org@localhost>
date:      Wed May 09 16:40:59 2001 +0000

description:
* change wait_for_pids() to spin forever (rather than just ~ 65 seconds).
* change the default `stop' case to wait_for_pids after kill $sig_stop.
  this means that "/etc/rc.d/foo stop" won't return until the service
  has shut down. third party scripts that implement their own stop mechanism
  should offer this functionality as well.
* in the default restart case, don't bother doing `$0 poll' in between
  stop & start, because of the change above. (XXX: deprecate poll ?)

diffstat:

 etc/rc.subr |  31 ++++++++++++++++++-------------
 1 files changed, 18 insertions(+), 13 deletions(-)

diffs (83 lines):

diff -r 826d565c670a -r eb0660d07f0d etc/rc.subr
--- a/etc/rc.subr       Wed May 09 16:28:10 2001 +0000
+++ b/etc/rc.subr       Wed May 09 16:40:59 2001 +0000
@@ -1,4 +1,4 @@
-# $NetBSD: rc.subr,v 1.34 2001/05/07 07:07:11 lukem Exp $
+# $NetBSD: rc.subr,v 1.35 2001/05/09 16:40:59 lukem Exp $
 #
 # Copyright (c) 1997-2000 The NetBSD Foundation, Inc.
 # All rights reserved.
@@ -159,8 +159,7 @@
 
 #
 # wait_for_pids pid [pid ...]
-#      spins until none of the pids exist or loop finally terminates
-#      (~ 65 seconds)
+#      spins until none of the pids exist
 #
 wait_for_pids()
 {
@@ -168,8 +167,8 @@
        if [ -z "$_list" ]; then
                return
        fi
-       echo -n "Waiting for PIDs: $_list"
-       for _i in 1 1 1 1 2 2 2 3 3 4 5 6 7 8 9 10; do
+       _prefix=
+       while true; do
                _nlist="";
                for _j in $_list; do
                        if kill -0 $_j 2>/dev/null; then
@@ -180,10 +179,13 @@
                        break
                fi
                _list=$_nlist
-               sleep $_i
-               echo -n ", $_list"
+               echo -n ${_prefix:-"Waiting for PIDS: "}$_list
+               _prefix=", "
+               sleep 2
        done
-       echo "."
+       if [ -n "$_prefix" ]; then
+               echo "."
+       fi
 }
 
 #
@@ -268,12 +270,15 @@
 #                              ${command}
 #
 #      stop            if ${pidfile}
-#                              kill $sig_stop `check_pidfile $pidfile`
+#                              _pid=`check_pidfile $pidfile`
 #                      else
-#                              kill $sig_stop `check_process $command`
-#                      $sig_stop defaults to TERM.
+#                              _pid=`check_process $command`
+#                      kill $sig_stop $_pid
+#                      wait_for_pids $_pid
+#                      ($sig_stop defaults to TERM.)
 #
-#      reload          As stop, except use $sig_reload instead.
+#      reload          Similar to stop, except use $sig_reload instead,
+#                      and doesn't wait_for_pids.
 #                      $sig_reload defaults to HUP.
 #
 #      restart         Run `stop' then `start'.
@@ -467,6 +472,7 @@
                                _doit="su -m $_user -c 'sh -c \"$_doit\"'"
                        fi
                        eval $_doit
+                       wait_for_pids $_pid
                        ;;
 
                reload)
@@ -503,7 +509,6 @@
                        _rc_restart_done=YES
 
                        ( $0 ${_rc_force_run:+force}stop )
-                       ( $0 ${_rc_force_run:+force}poll )
                        $0 ${_rc_force_run:+force}start
 
                        ;;



Home | Main Index | Thread Index | Old Index