Bug#41554: dpkg: start-stop-daemon --pidfile behaviour doesn't match documentation
Package: dpkg
Version: 1.4.1.3
Severity: normal
Hi,
I experimented a bit with start-stop-daemon and found that the passage on
the --pidfile switch in the manpage doesn't accurately describe the actual
behaviour of the program. It says in the manpage
With --start , start-stop-daemon checks for the existence
of a specified process. If such a process exists,
start-stop-daemon does nothing, and exits with error sta
tus 1 (0 if --oknodo is specified). If such a process
does not exist, it starts an instance, using either the
executable specified by --exec , (or, if specified, by
--startas ). Any arguments given after -- on the command
line are passed unmodified to the program being started.
...
-p|--pidfile pid-file
Check for processes whose process-id is specified
in pid-file.
This would imply that start-stop-daemon reads the pidfile, and if it finds a
process with the PID from the pidfile running, it doesn't start a new
instance; if not, it does. However, all start-stop-daemon is really
concerned about is the _existence_ of the pidfile. Allow me to demonstrate:
[guy@utopia ~]$ start-stop-daemon -t --start --pidfile $SSH2_AGENT_PIDFILE --startas /usr/bin/ssh-agent2
Would start /usr/bin/ssh-agent2 .
[guy@utopia ~]$ start-stop-daemon --start --pidfile $SSH2_AGENT_PIDFILE --startas /usr/bin/ssh-agent2
SSH2_AUTH_SOCK=/tmp/ssh-guy/ssh2-6134-agent; export SSH2_AUTH_SOCK;
SSH2_AGENT_PID=6135; export SSH2_AGENT_PID;
echo Agent pid 6135;
[guy@utopia ~]$ echo 6135 >$SSH2_AGENT_PIDFILE
[guy@utopia ~]$ start-stop-daemon -t --start --pidfile $SSH2_AGENT_PIDFILE --startas /usr/bin/ssh-agent2
(null) already running.
[guy@utopia ~]$ kill 6135
[guy@utopia ~]$ pidof ssh-agent2
[guy@utopia ~]$ start-stop-daemon -t --start --pidfile $SSH2_AGENT_PIDFILE --startas /usr/bin/ssh-agent2
(null) already running.
[guy@utopia ~]$ rm $SSH2_AGENT_PIDFILE
[guy@utopia ~]$ start-stop-daemon -t --start --pidfile $SSH2_AGENT_PIDFILE --startas /usr/bin/ssh-agent2
Would start /usr/bin/ssh-agent2 .
OR, instead of the rm command above:
[guy@utopia ~]$ start-stop-daemon -t --start --pidfile $SSH2_AGENT_PIDFILE --exec /usr/bin/ssh-agent2 --startas /usr/bin/ssh-agent2
Would start /usr/bin/ssh-agent2 .
So, specifying --exec along with --pidfile works. This is also evident after
a look at the output of strace.
Imho either the documentation should state more clearly that --pidfile only
makes sense if used along with --exec, or the program should be modified so
that it behaves in the way implied by the documentation. Personally, I would
prefer the latter.
Regards,
--
Andrew Korn (Korn Andras) <korn@eik.bme.hu> http://goliat.eik.bme.hu/~korn
Finger korn@goliat.eik.bme.hu for pgp key. Homepage is obsolete. QOTD:
Can't learn to do it well? Learn to enjoy doing it badly!
-- System Information
Debian Release: potato
Kernel Version: Linux utopia 2.2.10-ac10 #57 Wed Jul 14 14:08:37 CEST 1999 i586 unknown
Versions of the packages dpkg depends on:
ii libc6 2.1.1-12 GNU C Library: Shared libraries and timezone
ii libncurses4 4.2-3.2 Shared libraries for terminal handling
ii libstdc++2.9-gl 2.91.66-2 The GNU stdc++ library (EGCS version)
Reply to: