Scripts too - this causes the program to also return process id's of
shells running the named scripts.
.IP "-o \fIomitpid\fP"
-Tells \fIpidof\fP to omit processes with that process id.
+Tells \fIpidof\fP to omit processes with that process id. The special
+pid \fB%PPID\fP can be used to name the parent process of the \fIpidof\fP
+program, in other words the calling shell or shell script.
.SH "EXIT STATUS"
.TP
.B 0
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) {
xwarnx(_("illegal omit pid value (%s)!\n"), omit_str);
}
- omit_str = strtok(NULL, ",");
+ omit_str = strtok(NULL, ",;:");
}
}