problem with start-stop-daemon and --exec
Ed W
lists at wildgooses.com
Mon Mar 5 18:00:59 UTC 2012
On 05/03/2012 16:09, Denys Vlasenko wrote:
> On Mon, Mar 5, 2012 at 4:55 PM, Ed W<lists at wildgooses.com> wrote:
>> 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?
> Now they seem to use /proc/pid/stat. Gosh... that's supposed to be used
> for --name match!
I'm not sure that I understand how that would be so in my case?
# cat /proc/12754/stat
12754 (nginx) S 1 12754 12754 0 -1 4202560 61 0 0 0 0 0 0 0 20 0 1 0
310893428 34033664 203 18446744073709551615 1 1 0 0 0 0 0 1073745920
402745863 0 0 0 17 2 0 0 0 0 0
>>> 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
> Doesn't look like reasonable request for me.
Can you highlight what you object to please?
To be clear though - all I want to achieve is:
start-stop-daemon --stop --exec /usr/sbin/nginx --pidfile
/var/run/nginx.pid
To kill process:
# cat /proc/12754/cmdline
nginx: master process /usr/sbin/nginx -c /etc/nginx/nginx.conf
> And /proc/pid/exe match will also work.
> IOW: the fix I committed should be enough. No?
I believe your fix would work for the nginx case, but I think it won't
be sufficient to match a busybox executable (or similar hardlinked type
application) which changes it's cmdline?
On the other hand simply looking for the --exec string to match anywhere
in the /proc/pid/cmdline appears to solve both cases, ie use strstr
rather than strcmp?
As long as I can kill all my processes I don't think I care - just
seemed that swapping to a strstr, ie substring match seems simpler?
Is the verdict to stick with /proc/pid/exe though?
Cheers
Ed W
More information about the busybox
mailing list