From ce97bdb3110752749c2431e5fe930b56f94dbcef Mon Sep 17 00:00:00 2001 From: Didier Raboud Date: Mon, 16 Apr 2012 10:09:09 +0200 Subject: [PATCH] pidofproc(): Make sure to try /bin/pidof when no pidfile is specified. Move the pidof-using block inside the conditional to have it run when we know that the pidfile doesn't exist but before assuming that the program was indeed using one. Closes: #668958 Reported-by: Adrian Fita Signed-off-by: Didier Raboud --- init-functions | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/init-functions b/init-functions index 3be5648..512f1bf 100644 --- a/init-functions +++ b/init-functions @@ -100,17 +100,18 @@ pidofproc () { return 4 # pid file not readable, hence status is unknown. fi else - return 3 # pid file doesn't exist, program probably stopped + # pid file doesn't exist, try to find the pid nevertheless + if [ -x /bin/pidof ] && [ ! "$specified" ]; then + status="0" + /bin/pidof -o %PPID -x $1 || status="$?" + if [ "$status" = 1 ]; then + return 3 # program is not running + fi + return 0 + fi + return 3 # specified pid file doesn't exist, program probably stopped fi fi - if [ -x /bin/pidof ] && [ ! "$specified" ]; then - status="0" - /bin/pidof -o %PPID -x $1 || status="$?" - if [ "$status" = 1 ]; then - return 3 # program is not running - fi - return 0 - fi if [ "$specified" ]; then return 3 # almost certain it's not running fi -- 2.30.2