Re: [PATCH] Add --cmdpart to filter processes by argv elements.
On 15 September 2014 16:21, Guillem Jover <email@example.com> wrote:
> On Wed, 2014-09-10 at 22:29:10 +0200, Clemens Fruhwirth wrote:
>> The user can supplies a list of strings by using --cmdpart multiple
>> times, such as
>> $ start-stop-daemon --cmdpart /usr/bin/python --cmdpart mydaemon.py ....
>> This list is prefix-matched against the argv list of existing
>> processes. Only matching processes are considered to be the daemon in
>> question. As by the example above, the main intended use case is
>> allowing start-stop-daemon to detect running scripts.
> Ah! Yes, I started working on a solution for this some time ago, that
> instead would be automatic, by reading the executable and detecting
> if it's an interpreted script,
Reliability concerns aside, see
http://www.in-ulm.de/~mascheck/various/shebang/ , I am not sure that I
prefer an automatic solution. My approach while more cumbersome is
arguably more powerful as it's not just for scripts but can be reused
to regular daemons that run more than one instance. IIRC maradns used
to spawn a daemon for each network interface, and you could tell apart
the instances by the "-c $cfgfile" they got. This patch plus a bit of
argument reordering allows for separate control of each instance.
>> This is only implemented for Linux ATM, making use of
> I'm afraid that would be a non-starter.
Since your patch has exactly the same problem -- extracting the argv
from running processes -- would you mind basing your automatic
detection on my patch -- just fill cmdparts_c/cmdparts_v with your
detecting results -- and completing other OS implementations for
"static bool pid_has_cmdparts(pit_t pid)"? I, for my part, have zero
interest in contributing to non-GPL OS implementations.
Fruhwirth Clemens http://clemens.endorphin.org