From: Didier Raboud Date: Mon, 16 Apr 2012 08:09:09 +0000 (+0200) Subject: pidofproc(): Make sure to try /bin/pidof when no pidfile is specified. X-Git-Tag: archive/raspbian/10.2018112800+rpi1^2~156 X-Git-Url: https://dgit.raspbian.org/?a=commitdiff_plain;h=ce97bdb3110752749c2431e5fe930b56f94dbcef;p=lsb.git 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 --- 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