[arch-projects] [PATCH] get PID of shell scripts
Hi, get_pid() can now get the PID of a running shell script which is given as parameter. Signed-off-by: Andrwe Lord Weber <archlinux@andrwe.org> --- functions | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-) diff --git a/functions b/functions index f68c088..89215d8 100644 --- a/functions +++ b/functions @@ -242,7 +242,7 @@ ck_status() { # Return PID of $1 get_pid() { - pidof -o %PPID $1 || return 1 + pidof -o %PPID -x $1 || return 1 } # Check if PID-file $1 is still the active PID-file for command $2 -- 1.7.6
On Sun, Aug 28, 2011 at 7:40 PM, Andrwe Lord Weber <archlinux@andrwe.org> wrote:
get_pid() can now get the PID of a running shell script which is given as parameter.
Could you add a few words why we want this, preferably with a usecase, and also argue why this will not break any current users of get_pid()? Cheers, Tom
This modification just uses the parameter -x of pidof. It just adds the possibility to look for a script name: "Scripts too - this causes the program to also return process id's of shells running the named scripts." (manpage pidof(8)) So there won't be a break of current uses of this function. I've also done some tests and the results are always the same wether you use -x for getting pid of normal programs or not. A usecase is a script I've written which runs as daemon and which I wanted to start using an initscript. Because it expands the functionality without loosing some I think it's worth adding. Kind regards, Amdrwe On Sun, 28 Aug 2011 20:22:01 +0200, Tom Gundersen wrote:
On Sun, Aug 28, 2011 at 7:40 PM, Andrwe Lord Weber <archlinux@andrwe.org> wrote:
get_pid() can now get the PID of a running shell script which is given as parameter.
Could you add a few words why we want this, preferably with a usecase, and also argue why this will not break any current users of get_pid()?
Cheers,
Tom
Hi, I just noticed that this patch will break the command rc.d because it will always return the pid of the rc.d command. So please don't apply it. Kind regards, Andrwe Am 28.08.2011 23:34, schrieb Andrwe:
This modification just uses the parameter -x of pidof. It just adds the possibility to look for a script name:
"Scripts too - this causes the program to also return process id's of shells running the named scripts." (manpage pidof(8))
So there won't be a break of current uses of this function. I've also done some tests and the results are always the same wether you use -x for getting pid of normal programs or not.
A usecase is a script I've written which runs as daemon and which I wanted to start using an initscript. Because it expands the functionality without loosing some I think it's worth adding.
Kind regards, Amdrwe
On Sun, 28 Aug 2011 20:22:01 +0200, Tom Gundersen wrote:
On Sun, Aug 28, 2011 at 7:40 PM, Andrwe Lord Weber <archlinux@andrwe.org> wrote:
get_pid() can now get the PID of a running shell script which is given as parameter.
Could you add a few words why we want this, preferably with a usecase, and also argue why this will not break any current users of get_pid()?
Cheers,
Tom
On Sun, Oct 2, 2011 at 3:37 PM, Andrwe <archlinux@andrwe.org> wrote:
I just noticed that this patch will break the command rc.d because it will always return the pid of the rc.d command. So please don't apply it.
Thanks for pointing it out. -t
Am 28.08.2011 19:40, schrieb Andrwe Lord Weber:
Hi,
get_pid() can now get the PID of a running shell script which is given as parameter.
Signed-off-by: Andrwe Lord Weber <archlinux@andrwe.org>
Please include the project name in your subject (initscripts, mkinitcpio, abs, devtools, ...). This can be done with git format-patch --subject-prefix="projectname] [PATCH" ... or git send-email --subject-prefix="projectname] [PATCH" ... Thank you.
participants (4)
-
Andrwe
-
Andrwe Lord Weber
-
Thomas Bächler
-
Tom Gundersen