Procházet zdrojové kódy

Correctly determine current state in init script

If two stop actions are ever performed simultaneously, then neither will terminate.
With the default implementaiton of __pids_pidof, the status() function from 
/etc/init.d/functions incorrectly thinks the other stop action is a real 
corosync process.


git-svn-id: http://svn.fedorahosted.org/svn/corosync/trunk@2639 fd59a12c-fef9-0310-b244-a6a79926bd2f
Andrew Beekhof před 16 roky
rodič
revize
e725dd3edd
1 změnil soubory, kde provedl 9 přidání a 0 odebrání
  1. 9 0
      init/generic.in

+ 9 - 0
init/generic.in

@@ -62,6 +62,15 @@ if [ -d @SYSCONFDIR@/default ]; then
 	[ -z "$LOCK_FILE" ] && LOCK_FILE="@LOCALSTATEDIR@/lock/$prog"
 	[ -z "$LOCK_FILE" ] && LOCK_FILE="@LOCALSTATEDIR@/lock/$prog"
 fi
 fi
 
 
+# The version of __pids_pidof in /etc/init.d/functions calls pidof with -x
+# This means it matches scripts, including this one.
+# Redefine it here so that status (from the same file) works.
+# Otherwise simultaneous calls to stop() will loop forever
+__pids_pidof() {
+        pidof -c -o $$ -o $PPID -o %PPID "$1" || \
+                pidof -c -o $$ -o $PPID -o %PPID "${1##*/}"
+}
+
 start()
 start()
 {
 {
 	echo -n "Starting $desc ($prog): "
 	echo -n "Starting $desc ($prog): "