[PATCH 2/2] start-stop-daemon - find processes better
Roy Marples
roy at marples.name
Thu May 1 04:09:52 PDT 2008
On Thursday 01 May 2008 08:53:44 Denys Vlasenko wrote:
> Hereby I am informing all interested parties that
> I am totally confused now.
>
> I am not using ssd and I need your help
> in making a decent documentation how it work
> (or supposed to)
The Debian man page was never that clear either.
I re-wrote it to match my interpretation. You can find an online version here.
http://roy.marples.name/cgi-bin/man.cgi?8+start-stop-daemon
>
> Let's see what help says, and whether it matches reality
> (I deleted some obvious options):
>
> # start-stop-daemon --help
> Usage: start-stop-daemon [OPTIONS] [--start|--stop] ... [-- arguments...]
> Start and stop services
> Options:
> -S,--start Start
> -K,--stop Stop
> -a,--startas pathname Start process specified by pathname
> WRONG? it seems to just set argv[0].
> It's not a pathname, it's just a "name" (arbitrary)
Correct. It's a crap option. Gentoo silently remaps it to --exec
> -u,--user username|uid Stop this user's processes
> Clarification? Will e.g. "ssd -K -u roy" stop
> all roy's processes?
Yes
> -x,--exec executable Program to either start or check
> Waht does it mean "check"? "stop"?
> How executable is searched for for "stop" case?
My view is that it searches for programs started as that.
So if the user launches /usr/sbin/ntpd then ssd should check /proc/pid/cmdline
to see if it was started as /usr/sbin/ntpd and then match.
OpenRC extends this futher and also matches daemon arguments. Thus, this works
start-stop-damon --start --exec /usr/sbin/daemon -- --hostname foo
start-stop-damon --start --exec /usr/sbin/daemon -- --hostname bar
start-stop-damon --stop --exec /usr/sbin/daemon -- --hostname foo
the second daemon *should* still be running in my eyes.
However, adding that will bloat ssd a little more, so may not be beneficial
for busybox.
> -n,--name process-name Stop processes with this name
> Is it equivalent to "killall name"?
> If not, what's the difference?
Should be equivalent.
This is a bad option to use as many daemon love to change their process name
AND don't create a pidfile AND are scripts. Again, this is why we
changed --exec to look at how it was started to solve this problem.
> -p,--pidfile pid-file Save or load pid using a pid-file
> -m,--make-pidfile Create the -p file and enter pid in it
> ?? How "save" is different from "create and enter pid in it"?
In normal ssd, -p only matters when stopping. It reads the specified file and
just stops that pid.
However, ssd can also background some daemons which don't by default. Or which
don't create a pidifle by default. So the solution is to run the daemon in
foreground mode in a forked process. We then store that pid in the pidfile.
Example
start-stop-daemon --start --exec /usr/sbin/daemon --pidfile /var/run/daemon.pid --make-pidfile -- --foreground
--foreground is an option specific to daemon and not start-stop-daemon.
Thanks
Roy
More information about the busybox
mailing list