From e725dd3edd9916b8199166a45b17d3e54a744b49 Mon Sep 17 00:00:00 2001 From: Andrew Beekhof Date: Tue, 15 Dec 2009 11:52:48 +0000 Subject: [PATCH] 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 --- init/generic.in | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/init/generic.in b/init/generic.in index 12236c17..261ceafb 100755 --- a/init/generic.in +++ b/init/generic.in @@ -62,6 +62,15 @@ if [ -d @SYSCONFDIR@/default ]; then [ -z "$LOCK_FILE" ] && LOCK_FILE="@LOCALSTATEDIR@/lock/$prog" 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() { echo -n "Starting $desc ($prog): "