Merge branch 'jrybar/procps-pidof-show-worker-pids'

References:
 procps-ng/procps!101
This commit is contained in:
Craig Small 2020-04-10 14:45:28 +10:00
commit 9c3296bae9

10
pidof.c
View File

@ -142,6 +142,7 @@ static void select_procs (void)
static int size = 0; static int size = 0;
char *cmd_arg0, *cmd_arg0base; char *cmd_arg0, *cmd_arg0base;
char *cmd_arg1, *cmd_arg1base; char *cmd_arg1, *cmd_arg1base;
char *stat_cmd;
char *program_base; char *program_base;
char *root_link; char *root_link;
char *exe_link; char *exe_link;
@ -167,9 +168,10 @@ static void select_procs (void)
} }
} }
if (!is_omitted(task.XXXID) && task.cmdline && *task.cmdline) { if (!is_omitted(task.XXXID)) {
cmd_arg0 = *task.cmdline; cmd_arg0 = (task.cmdline && *task.cmdline) ? *task.cmdline : "\0";
stat_cmd = task.cmd ? task.cmd : "\0";
/* processes starting with '-' are login shells */ /* processes starting with '-' are login shells */
if (*cmd_arg0 == '-') { if (*cmd_arg0 == '-') {
@ -191,12 +193,14 @@ static void select_procs (void)
!strcmp(program_base, cmd_arg0) || !strcmp(program_base, cmd_arg0) ||
!strcmp(program, cmd_arg0) || !strcmp(program, cmd_arg0) ||
!strcmp(program, stat_cmd) ||
!strcmp(program, exe_link_base) || !strcmp(program, exe_link_base) ||
!strcmp(program, exe_link)) !strcmp(program, exe_link))
{ {
match = 1; match = 1;
} else if (opt_scripts_too && *(task.cmdline+1)) { } else if (opt_scripts_too && task.cmdline && *(task.cmdline+1)) {
cmd_arg1 = *(task.cmdline+1); cmd_arg1 = *(task.cmdline+1);