summaryrefslogtreecommitdiff
path: root/pidof.c
diff options
context:
space:
mode:
authorJaromir Capik <jcapik@redhat.com>2013-10-14 15:38:33 +0200
committerJaromir Capik <jcapik@redhat.com>2013-10-14 15:38:33 +0200
commitf5d15f471890ed8ae1006b0007ff1bc7a5b9476d (patch)
tree6a0cbf9495abb7820ce372fa75dbc360c643423c /pidof.c
parent8a2113bcf2aace12377e4d62e9dedc6f706c6a29 (diff)
downloadprocps-ng-f5d15f471890ed8ae1006b0007ff1bc7a5b9476d.tar.gz
pidof: support for omitted %PPID and additional separators
This commit introduces support for special %PPID value that can be passed to the -o option as a substitution for parent PID. It also allows users to use two additional separators for omitted PIDs - colon and semicolon.
Diffstat (limited to 'pidof.c')
-rw-r--r--pidof.c11
1 files changed, 8 insertions, 3 deletions
diff --git a/pidof.c b/pidof.c
index a39a4c0..72344e7 100644
--- a/pidof.c
+++ b/pidof.c
@@ -246,10 +246,15 @@ static void add_to_omit_list (char *input_arg)
pid_t omit_pid;
omit_str = NULL;
- omit_str = strtok(input_arg, ",");
+ omit_str = strtok(input_arg, ",;:");
while (omit_str) {
- omit_pid = strtoul(omit_str, &endptr, 10);
+ if (!strcmp(omit_str,"%PPID")) { /* keeping this %PPID garbage for backward compatibility only */
+ omit_pid = getppid(); /* ... as it can be replaced with $$ in common shells */
+ endptr = omit_str + sizeof("%PPID") - 1;
+ } else {
+ omit_pid = strtoul(omit_str, &endptr, 10);
+ }
if (*endptr == '\0') {
if (omit_count == omit_size) {
@@ -265,7 +270,7 @@ static void add_to_omit_list (char *input_arg)
xwarnx(_("illegal omit pid value (%s)!\n"), omit_str);
}
- omit_str = strtok(NULL, ",");
+ omit_str = strtok(NULL, ",;:");
}
}