[arch-general] [PATCH 21/48] Both rc.single and rc.shutdown use the same code to kill everything.
Kurt J. Bosch
kjb-temp-2009 at alpenjodel.de
Tue Aug 31 04:07:52 EDT 2010
2010-07-02 11:27, Thomas Bächler:
> First of all, sorry for not continuing the review yesterday, time is
> short :(
>
> Still, I'll finish this, as I'd like to have this applied eventually.
>
> Am 02.07.2010 11:21, schrieb Kurt J. Bosch:
>> Am 2010-06-30 23:47, schrieb Victor Lowther:
>>> Move that shared code into functions.
>>> + run_hook single_prekillall
>>
>> This line should be run_hook "${0##*/rc.}"_prekillall IMHO
>
> Kurt is right here. We call this code from rc.single and rc.shutdown I
> think. We use two distinct hooks, you can register functions for these
> hooks independently!
>
Hmm, git bashification-redux has now:
kill_everything() {
# $1 = where we are being called from.
# This is used to determine which hooks to run.
# Find daemons NOT in the DAEMONS array. Shut these down first
for daemon in /var/run/daemons/*; do
[[ -f $daemon ]] || continue
daemon=${daemon##*/}
in_array "$daemon" "${DAEMONS[@]}" || stop_daemon "$daemon"
done
# Shutdown daemons in reverse order
for ((i=${#DAEMONS[@]}-1; i>=0; i--)); do
[[ ${DAEMONS[$i]:0:1} = '!' ]] && continue
ck_daemon ${DAEMONS[$i]#@} || stop_daemon ${DAEMONS[$i]#@}
done
# Terminate all processes
stat_busy "Sending SIGTERM To Processes"
run_hook "$1_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 "$1_postkillall"
}
I suggest:
From b202be97f8dc1c0c68aaea792d4457c674c673f3 Mon Sep 17 00:00:00 2001
From: Kurt J. Bosch <kjb-temp-2009 at alpenjodel.de>
Date: Tue, 31 Aug 2010 09:57:47 +0200
Subject: [PATCH 17/17] Correct behaviour of kill_everything()
---
functions | 11 +++++------
1 files changed, 5 insertions(+), 6 deletions(-)
diff --git a/functions b/functions
index b9ba718..3ca7324 100644
--- a/functions
+++ b/functions
@@ -205,10 +205,9 @@ ck_status() {
kill_everything() {
# $1 = where we are being called from.
# This is used to determine which hooks to run.
- # Find daemons NOT in the DAEMONS array. Shut these down first
- for daemon in /var/run/daemons/*; do
- [[ -f $daemon ]] || continue
- daemon=${daemon##*/}
+ # Find daemons NOT in the DAEMONS array.
+ # Shut these down first in reverse order.
+ for daemon in $( /bin/ls -t /var/run/daemons ); do
in_array "$daemon" "${DAEMONS[@]}" || stop_daemon "$daemon"
done
@@ -220,7 +219,7 @@ kill_everything() {
# Terminate all processes
stat_busy "Sending SIGTERM To Processes"
- run_hook "$1_prekillall"
+ run_hook "${1}_prekillall"
/sbin/killall5 -15 &> /dev/null
/bin/sleep 5
stat_done
@@ -230,7 +229,7 @@ kill_everything() {
/bin/sleep 1
stat_done
- run_hook "$1_postkillall"
+ run_hook "${1}_postkillall"
}
activate_vgs() {
--
1.7.0.3
More information about the arch-general
mailing list