problem with start-stop-daemon and --exec

Ed W lists at wildgooses.com
Mon Mar 5 15:55:45 UTC 2012


On 05/03/2012 15:33, Denys Vlasenko wrote:
> On Mon, Mar 5, 2012 at 4:25 PM, Ed W<lists at wildgooses.com>  wrote:
>>> But there is a reason why we check /proc/pid/cmdline instead.
>>> On systems with bbox, a lot of processes will have
>>> /proc/pid/exe = "/bin/busybox".
>>> Which will make e.g.
>>> start-stop-daemon --stop --exec /bin/ntpd
>>> fail to stop ntpd if ntpd is a busybox applet.
>> I examined the code for openrc and I can't find any obvious reference to
>> /proc/pid/exe ?  I confess I don't understand the implementation they are
>> using, but I think the relevant code is in src/librc/librc-daemon.c if
>> someone else could take a closer look?
> http://sources.gentoo.org/cgi-bin/viewvc.cgi/baselayout/trunk/src/librc-daemon.c?view=markup&pathrev=2966

That code seems to be gone?

I'm using openrc-0.9.8.4.  That file you referenced now looks like this:
     
http://git.overlays.gentoo.org/gitweb/?p=proj/openrc.git;a=blob;f=src/librc/librc-daemon.c;h=982da354da586dbb48766ae626de8b9f2b7a0335;hb=14b7f0e7fa1069827138d931952487b7c7db0d6a

I'm actually struggling to get my head around how it's doing it's 
thing...  However, I don't obviously see that it's using /proc/pid/exe?


>> Can we please consider simply relaxing the current test to be a substring
>> match on /proc/pid/cmdline (only in the case of both --exec AND --pidfile)?


> I don't fully understand. Can you show a patch?

Well, perhaps an illustration.  This works and kills the process 
/usr/sbin/nginx:

	start-stop-daemon --stop --exec inx --pidfile /var/run/nginx.pid


This does not:

	start-stop-daemon --stop --exec xxx --pidfile /var/run/nginx.pid


Note I don't recommend it's usually used like this (abbreviated --exec), 
but substring matching *would* work for my situation (currently using 
"/usr/sbin/nginx") and likely the common situation.  To recap:

$ cat /proc/3676/cmdline
nginx: master process /usr/sbin/nginx -c /etc/nginx/nginx.conf

$ ls -l /proc/3676/exe
lrwxrwxrwx    1 root     root             0 Mar  5 15:52 /proc/3676/exe 
-> /usr/sbin/nginx

I also have a lot of busybox executables, so for example I also want to 
run s-s-d against crond:

$ ls -al /usr/sbin/crond
lrwxrwxrwx    1 root     root            17 Mar  5 12:17 /usr/sbin/crond 
-> ../../bin/busybox


Thanks

Ed W


More information about the busybox mailing list