[Pkg-sysvinit-devel] Bug#482817: pidofproc and %PPID
John van der Kamp
john at kirika.demon.nl
Fri Nov 28 21:58:46 UTC 2008
Hi,
I've been trying to debug this myself too, and actually thought like in
bug #506995 that portmap was running twice, since it would be started from
/etc/rcS.d/S40networking (which kicks /etc/network/if-up.d/nfsmount.sh)
and also from /etc/rcS.d/S43portmap.
So I disabled the rcS.d portmap and nfs-common since the nfsmount.sh
script would start them, but then I still had the problem!
As far as I can tell now, /etc/init.d/portmap does:
pid=$( pidofproc portmap )
The $() starts a new process, and pidof -o %PPID uses this as parent pid.
But the /etc/init.d/portmap script is also running, and recognized, making
the pidof program return a of the init.d script.
I've fix it like this, but you're welcome to make your own conclusions and
fixes :)
--- /etc/init.d/portmap.old 2008-11-28 22:49:01.359743640 +0100
+++ /etc/init.d/portmap 2008-11-28 22:49:07.680869696 +0100
@@ -30,8 +30,8 @@
case "$1" in
start)
log_begin_msg "Starting portmap daemon..."
- pid=$( pidofproc portmap )
- if [ -n "$pid" ] ; then
+ pidofproc portmap >/dev/null
+ if [ "$?" = 0 ] ; then
log_begin_msg "Already running."
log_end_msg 0
exit 0
Since I don't know of a way to capture the output in a variable without
using $() or ``, I let it check the return value of pidofproc.
John
More information about the Pkg-sysvinit-devel
mailing list