pidof: show worker threads

Reimplementation of pidof for procps toolset contains sort of deactivated code and does not return results for processes without task.cmdline entry (usually kernel worker threads). Old pidof and pgrep do that in comparison. Despite all perks provided by using pgrep instead, pidof should show those workers again.
This commit is contained in:
Jan Rybar 2020-04-07 13:41:48 +02:00 committed by Craig Small
parent f5a6f4af6d
commit 6f9565b3c7
1 changed files with 6 additions and 3 deletions

View File

@ -145,6 +145,7 @@ static void select_procs (void)
static int size = 0;
char *cmd_arg0, *cmd_arg0base;
char *cmd_arg1, *cmd_arg1base;
char *stat_cmd;
char *program_base;
char *root_link;
char *exe_link;
@ -172,9 +173,9 @@ static void select_procs (void)
}
}
if (!is_omitted(tid) && p_cmdline && *p_cmdline) {
if (!is_omitted(tid)) {
cmd_arg0 = *p_cmdline;
cmd_arg0 = (p_cmdline && *p_cmdline) ? *p_cmdline : "\0";
/* processes starting with '-' are login shells */
if (*cmd_arg0 == '-') {
@ -196,12 +197,14 @@ static void select_procs (void)
!strcmp(program_base, cmd_arg0) ||
!strcmp(program, cmd_arg0) ||
!strcmp(program, stat_cmd) ||
!strcmp(program, exe_link_base) ||
!strcmp(program, exe_link))
{
match = 1;
} else if (opt_scripts_too && *(p_cmdline+1)) {
} else if (opt_scripts_too && p_cmdline && *(p_cmdline+1)) {
cmd_arg1 = *(p_cmdline+1);