From 9390083d675e1fd5059ab35d9977bf84b7d87ba2 Mon Sep 17 00:00:00 2001 From: Victor Lowther Date: Mon, 7 Jun 2010 10:24:43 -0500 Subject: Both rc.single and rc.shutdown use the same code to kill everything. Simplify it, and move that shared code into functions. Parsing the output of ls is Bad, especially when globbing works just as well and does not get confused by odd characters in filenames. bash has arithemetic for loops. Use them instead of while loops for iterating over arrays. --- rc.single | 33 +-------------------------------- 1 file changed, 1 insertion(+), 32 deletions(-) (limited to 'rc.single') diff --git a/rc.single b/rc.single index aa58b4c..2e757d9 100755 --- a/rc.single +++ b/rc.single @@ -9,38 +9,7 @@ run_hook single_start if [[ $PREVLEVEL != N ]]; then - - # Find daemons NOT in the DAEMONS array. Shut these down first - if [[ -d /var/run/daemons ]]; then - for daemon in $(/bin/ls -1t /var/run/daemons); do - if ! in_array $daemon ${DAEMONS[@]}; then - stop_daemon $daemon - fi - done - fi - # Shutdown daemons in reverse order - let i=${#DAEMONS[@]}-1 - while ((i >= 0)); do - if [[ ${DAEMONS[$i]:0:1} != '!' ]]; then - ck_daemon ${DAEMONS[$i]#@} || stop_daemon ${DAEMONS[$i]#@} - fi - let i=i-1 - done - - # Terminate all processes - stat_busy "Sending SIGTERM To Processes" - run_hook single_prekillall - /sbin/killall5 -15 &> /dev/null - /bin/sleep 5 - stat_done - - stat_busy "Sending SIGKILL To Processes" - /sbin/killall5 -9 &> /dev/null - /bin/sleep 1 - stat_done - - run_hook single_postkillall - + kill_everything single stat_busy "Starting UDev Daemon" /sbin/udevd --daemon stat_done -- cgit v1.2.3