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

Roy Marples roy at marples.name
Wed Apr 30 16:19:16 UTC 2008


On Wednesday 30 April 2008 16:25:10 Joakim Tjernlund wrote:
> > But the intent of start-stop-daemon is to start and stop daemons.
> > s-s-d --stop --exec /usr/sbin/ntpd
> > I would that expect it to stop the currently running ntpd process
> > regardless of if the binary itself still exists or not.
>
> Don't think so, this is what --name is for. At least I think so.

--name is for checking the process name, or argv[0], which is different from 
how the daemon is started.

>
> > > > It
> > > > wont work when cmdline i a symlink. Should you not use --name instead
> > > > to handle the deleted case?
> >
> > But this is good :)
> > Consider busybox - loads of things symlink into it, like udhcpd. So are
> > you stopping udhcpd or all instances of busybox daemons?
>
> You won't stop anything with your solution because /proc/xxx/exe
> contains the real file name. So
>   s-s-d --stop --exec /bin/mysymlinkeddaemon
> will not match.

Good point.
New patch attached which just checks cmdline instead of doing exe then 
cmdline.

function                                             old     new   delta
start_stop_daemon_main                               984    1006     +22
.rodata                                           119312  119303      -9
check                                                755     714     -41
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 1/2 up/down: 22/-50)            Total: -28 bytes

So that's now an overall code shrink :)

Also you should consider the case of scripts. If /usr/bin/foo is  a python 
script, and was started like
start-stop-daemon --start --exec /usr/bin/foo
then you could reasonably expect
start-stop-daemon --stop --exec /usr/bin/foo
to work. However it won't because the exe inode points at python and not the 
script.

Thanks

Roy
-------------- next part --------------
A non-text attachment was scrubbed...
Name: bb-ssd-proc.patch
Type: text/x-diff
Size: 1930 bytes
Desc: not available
Url : http://lists.busybox.net/pipermail/busybox/attachments/20080430/b5f8e8c9/attachment.bin 


More information about the busybox mailing list