[PATCH 2/2] start-stop-daemon - find processes better

Roy Marples roy at marples.name
Thu May 1 13:38:19 UTC 2008


On Thursday 01 May 2008 14:18:40 Denys Vlasenko wrote:
> > >         -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
>
> Are you suggesting to drop it? This risks breaking
> things for existing users.

No, I'm suggesting just to remap --startas 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
>
> And what does it mean for --start case?
> ssd -S -u roy -x /usr/bin/sleep 1234

If /usr/bin/sleep is currently running AND owned by roy then ssd should say 
it's already running, otherwise try and start it.
Remember, ssd does processes matching for starting as well.

>
> > >         -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.
>
> And what to do if cmdline contains just "ntpd"? or "./ntpd"?
> Does that match?
> Do we need to check /proc/$PID/stat? /proc/$PID/exec?

That's the one hole really :)
It doesn't match, but then I don't expect it too either. ssd is normally used 
in scripts, so the way it's started should match the way it's stopped.

> > 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
>
> Change process name? How?

Normally they just change their argv[0], but this depends on platform.
The BSD's have a libc call.

> > 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.
>
> How it is different from -x?

-x is --exec, or did I miss something?

>
> > >         -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.
>
> But --make-pidfile seems to be superfluous here... --start + --pidfile FILE
> imply pidfile creation.

Not so as --pidfile is used to check processes before the demon starts

start-stop-daemon --start --exec /usr/bin/foo --pidfile /var/run/foo.pid

Check that /usr/bin/foo is NOT running on the pidfile in /var/run/foo.pid.
If not running, start foo, otherwise error.
ssd should not stamp on pidfiles unless told.

Thanks

Roy



More information about the busybox mailing list