problem with start-stop-daemon and --exec

Denys Vlasenko vda.linux at googlemail.com
Mon Mar 5 15:05:55 UTC 2012


On Mon, Mar 5, 2012 at 2:06 AM, Ed W <lists at wildgooses.com> wrote:
> On 04/03/2012 16:30, ralda at gmx.de wrote:
>>>> start-stop-daemon --stop --pidfile /var/run/nginx.pid
>>>
>>> Yes this works.  Up until recently that's exactly what gentoo used,
>>> but they have now started to switch their init scripts to be more
>>> specific with --exec
>>>
>>> I guess this also defends against services which die in the
>>> background and something else ends up accidently running on the same
>>> pid
>>
>> My start-stop-daemon from Gentoo killed processes if they EITHER
>> matched the pid from file OR the given exec name. As this killed
>> sometimes the wrong process I switched to Busybox start-stop-daemon
>> witch killed only the process when both conditions met (pid AND name).
>> But that test was back in last year spring. May be things changed since
>> this.
>
> Testing with openrc-0.9.8.2 I see that it's an "AND" and further that either
> mangling my pid file or selecting only --exec fails to kill my process

Yes:

BusyBox v1.20.0.git (2012-02-23 13:42:51 CET) multi-call binary.

Usage: start-stop-daemon [OPTIONS] [-S|-K] ... [-- ARGS...]

Search for matching processes, and then
-K: stop all matching processes.
-S: start a process unless a matching process is found.

Process matching:
	-u,--user USERNAME|UID	Match only this user's processes
	-n,--name NAME		Match processes with NAME
				in comm field in /proc/PID/stat
	-x,--exec EXECUTABLE	Match processes with this command
				in /proc/PID/cmdline
	-p,--pidfile FILE	Match a process with PID from the file
	All specified conditions must match
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
-S only:
	-x,--exec EXECUTABLE	Program to run
	-a,--startas NAME	Zeroth argument
	-b,--background		Background
	-N,--nicelevel N	Change nice level
	-c,--chuid USER[:[GRP]]	Change to user/group
	-m,--make-pidfile	Write PID to the pidfile specified by -p
-K only:
	-s,--signal SIG		Signal to send
	-t,--test		Match only, exit with 0 if a process is found
Other:
	-o,--oknodo		Exit with status 0 if nothing is done
	-v,--verbose		Verbose
	-q,--quiet		Quiet


More information about the busybox mailing list