Blame SOURCES/procps-ng-3.3.15-pidof-show-worker-threads.patch

4a743f
From 7dcb6b8eb6c69584d0d56797935f836bc06642f5 Mon Sep 17 00:00:00 2001
4a743f
From: Jan Rybar <jrybar@redhat.com>
4a743f
Date: Tue, 7 Apr 2020 13:41:48 +0200
4a743f
Subject: [PATCH] pidof: show worker threads
4a743f
4a743f
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.
4a743f
---
4a743f
 pidof.c | 10 +++++++---
4a743f
 1 file changed, 7 insertions(+), 3 deletions(-)
4a743f
4a743f
diff --git a/pidof.c b/pidof.c
4a743f
index b0d08cc..90ecb13 100644
4a743f
--- a/pidof.c
4a743f
+++ b/pidof.c
4a743f
@@ -142,6 +142,7 @@ static void select_procs (void)
4a743f
 	static int size = 0;
4a743f
 	char *cmd_arg0, *cmd_arg0base;
4a743f
 	char *cmd_arg1, *cmd_arg1base;
4a743f
+	char *stat_cmd;
4a743f
 	char *program_base;
4a743f
 	char *root_link;
4a743f
 	char *exe_link;
4a743f
@@ -167,9 +168,10 @@ static void select_procs (void)
4a743f
 			}
4a743f
 		}
4a743f
 
4a743f
-		if (!is_omitted(task.XXXID) && task.cmdline && *task.cmdline) {
4a743f
+		if (!is_omitted(task.XXXID)) {
4a743f
 
4a743f
-			cmd_arg0 = *task.cmdline;
4a743f
+			cmd_arg0 = (task.cmdline && *task.cmdline) ? *task.cmdline : "\0";
4a743f
+			stat_cmd = task.cmd ? task.cmd : "\0";
4a743f
 
4a743f
 			/* processes starting with '-' are login shells */
4a743f
 			if (*cmd_arg0 == '-') {
4a743f
@@ -191,12 +193,14 @@ static void select_procs (void)
4a743f
 			    !strcmp(program_base, cmd_arg0) ||
4a743f
 			    !strcmp(program, cmd_arg0) ||
4a743f
 
4a743f
+			    !strcmp(program, stat_cmd) ||
4a743f
+
4a743f
 			    !strcmp(program, exe_link_base) ||
4a743f
 			    !strcmp(program, exe_link))
4a743f
 			{
4a743f
 				match = 1;
4a743f
 
4a743f
-			} else if (opt_scripts_too && *(task.cmdline+1)) {
4a743f
+			} else if (opt_scripts_too && task.cmdline && *(task.cmdline+1)) {
4a743f
 
4a743f
 				cmd_arg1 = *(task.cmdline+1);
4a743f
 
4a743f
-- 
4a743f
2.25.2
4a743f