[arch-projects] [initscripts] [PATCH 12/13] functions: Add stop_all_daemons() and related *_prestopdaemons hook

Kurt J. Bosch kjb-temp-2009 at alpenjodel.de
Sun Jul 3 16:31:14 EDT 2011


This allows splash systems etc. to get a list of daemons to be stopped by simply overriding stop_daemon().
---
 functions |   17 +++++++++++++----
 1 files changed, 13 insertions(+), 4 deletions(-)

diff --git a/functions b/functions
index 7054f60..9cc9cc6 100644
--- a/functions
+++ b/functions
@@ -279,10 +279,10 @@ add_omit_pids() {
 	omit_pids+=( $@ )
 }
 
-
-kill_everything() {
-	# $1 = where we are being called from.
-	# This is used to determine which hooks to run.
+# Stop all daemons
+# This function should *never* ever perform any other actions beside calling stop_daemon()!
+# It might be used by a splash system etc. to count or get a list of daemons to be stopped.
+stop_all_daemons() {
 	# Find daemons NOT in the DAEMONS array. Shut these down first
 	local daemon
 	for daemon in /run/daemons/*; do
@@ -297,6 +297,15 @@ kill_everything() {
 		[[ ${DAEMONS[i]} = '!'* ]] && continue
 		ck_daemon ${DAEMONS[i]#@} || stop_daemon ${DAEMONS[i]#@}
 	done
+}
+
+kill_everything() {
+	# $1 = where we are being called from.
+	# This is used to determine which hooks to run.
+
+	run_hook "$1_prestopdaemons"
+
+	stop_all_daemons
 
 	run_hook "$1_prekillall"
 
-- 
1.7.1



More information about the arch-projects mailing list