tags 668958 +patch
thanks
Le 16.04.2012 03:48, Adrian Fita a écrit :
> Hi.
>
> I noticed that "/etc/init.d/hddtemp status" wasn't returning the correct
> status when the daemon was running. hddtemp daemon doesn't create a pidfile
> when started, so I tracked the problem back to the pidofproc function
> from /lib/lsb/init-functions.
Hi Adrian, and thanks for your bugreport,
as far as I can see, this behaviour has been broken by my fix for #664621:
http://anonscm.debian.org/gitweb/?p=collab-maint/lsb.git;a=commitdiff;h=23c14db
> Basically I put the section with "if [ -x /bin/pidof ] && [ !
> "$specified" ]; then" before the section with "base=${1##*/}". Now the
> function is corectly detecting the pids and "/etc/init.d/hddtemp status"
> gives the right information. Please check the attached patch. I also
> tested the other daemons on my system, both with pidfiles and without
> and all seem to work fine.
This patch (besides being reversed) makes all "pidofproc with
unspecified pidfile name" calls call /bin/pidof, which is undesired IMHO.
I propose the attached patch, that only resorts to calling /bin/pidof
when the pidfile is provably inexistant and when it wasn't specified at
first.
Can you please test it and report back?
Cheers, OdyX
From 05b2f8781d80ede77c817c963583d674b3ae1502 Mon Sep 17 00:00:00 2001
From: Didier Raboud <odyx@debian.org>
Date: Mon, 16 Apr 2012 10:09:09 +0200
Subject: [PATCH] pidofproc(): Make sure to try /bin/pidof when no pidfile is specified.
Closes: #668958
Reported-by: Adrian Fita <adrian.fita@gmail.com>
Signed-off-by: Didier Raboud <odyx@debian.org>
---
init-functions | 19 ++++++++++---------
1 files 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
--
1.7.2.5
Attachment:
signature.asc
Description: OpenPGP digital signature