DistroBaker 660347
diff --git a/pidof.1 b/pidof.1
DistroBaker 660347
index 8ef4abf..5f95b85 100644
DistroBaker 660347
--- a/pidof.1
DistroBaker 660347
+++ b/pidof.1
DistroBaker 660347
@@ -45,6 +45,9 @@ the current root directory of processes they do not own.
DistroBaker 660347
 .IP \-x
DistroBaker 660347
 Scripts too - this causes the program to also return process id's of
DistroBaker 660347
 shells running the named scripts.
DistroBaker 660347
+.IP \-w
DistroBaker 660347
+Show also processes that do not have visible command line (e.g. kernel
DistroBaker 660347
+worker threads).
DistroBaker 660347
 .IP "-o \fIomitpid\fP"
DistroBaker 660347
 Tells \fIpidof\fP to omit processes with that process id. The special
DistroBaker 660347
 pid \fB%PPID\fP can be used to name the parent process of the \fIpidof\fP
DistroBaker 660347
diff --git a/pidof.c b/pidof.c
DistroBaker 660347
index 90ecb13..0754754 100644
DistroBaker 660347
--- a/pidof.c
DistroBaker 660347
+++ b/pidof.c
DistroBaker 660347
@@ -55,6 +55,8 @@ static char *program = NULL;
DistroBaker 660347
 static int opt_single_shot    = 0;  /* -s */
DistroBaker 660347
 static int opt_scripts_too    = 0;  /* -x */
DistroBaker 660347
 static int opt_rootdir_check  = 0;  /* -c */
DistroBaker 660347
+static int opt_with_workers   = 0;  /* -w */
DistroBaker 660347
+
DistroBaker 660347
 
DistroBaker 660347
 static char *pidof_root = NULL;
DistroBaker 660347
 
DistroBaker 660347
@@ -69,6 +71,7 @@ static int __attribute__ ((__noreturn__)) usage(int opt)
DistroBaker 660347
 	fputs(_(" -s, --single-shot         return one PID only\n"), fp);
DistroBaker 660347
 	fputs(_(" -c, --check-root          omit processes with different root\n"), fp);
DistroBaker 660347
 	fputs(_(" -x                        also find shells running the named scripts\n"), fp);
DistroBaker 660347
+	fputs(_(" -w, --with-workers        show kernel workers too\n"), fp);
DistroBaker 660347
 	fputs(_(" -o, --omit-pid <PID,...>  omit processes with PID\n"), fp);
DistroBaker 660347
 	fputs(_(" -S, --separator SEP       use SEP as separator put between PIDs"), fp);
DistroBaker 660347
 	fputs(USAGE_SEPARATOR, fp);
DistroBaker 660347
@@ -142,7 +145,6 @@ static void select_procs (void)
DistroBaker 660347
 	static int size = 0;
DistroBaker 660347
 	char *cmd_arg0, *cmd_arg0base;
DistroBaker 660347
 	char *cmd_arg1, *cmd_arg1base;
DistroBaker 660347
-	char *stat_cmd;
DistroBaker 660347
 	char *program_base;
DistroBaker 660347
 	char *root_link;
DistroBaker 660347
 	char *exe_link;
DistroBaker 660347
@@ -168,10 +170,9 @@ static void select_procs (void)
DistroBaker 660347
 			}
DistroBaker 660347
 		}
DistroBaker 660347
 
DistroBaker 660347
-		if (!is_omitted(task.XXXID)) {
DistroBaker 660347
+		if (!is_omitted(task.XXXID) && ((task.cmdline && *task.cmdline) || opt_with_workers)) {
DistroBaker 660347
 
DistroBaker 660347
 			cmd_arg0 = (task.cmdline && *task.cmdline) ? *task.cmdline : "\0";
DistroBaker 660347
-			stat_cmd = task.cmd ? task.cmd : "\0";
DistroBaker 660347
 
DistroBaker 660347
 			/* processes starting with '-' are login shells */
DistroBaker 660347
 			if (*cmd_arg0 == '-') {
DistroBaker 660347
@@ -193,7 +194,7 @@ static void select_procs (void)
DistroBaker 660347
 			    !strcmp(program_base, cmd_arg0) ||
DistroBaker 660347
 			    !strcmp(program, cmd_arg0) ||
DistroBaker 660347
 
DistroBaker 660347
-			    !strcmp(program, stat_cmd) ||
DistroBaker 660347
+			    (opt_with_workers && !strcmp(program, task.cmd)) ||
DistroBaker 660347
 
DistroBaker 660347
 			    !strcmp(program, exe_link_base) ||
DistroBaker 660347
 			    !strcmp(program, exe_link))
DistroBaker 660347
@@ -293,13 +294,14 @@ int main (int argc, char **argv)
DistroBaker 660347
 	int first_pid = 1;
DistroBaker 660347
 
DistroBaker 660347
 	const char *separator = " ";
DistroBaker 660347
-	const char *opts = "scdnxmo:S:?Vh";
DistroBaker 660347
+	const char *opts = "scdnxwmo:S:?Vh";
DistroBaker 660347
 
DistroBaker 660347
 	static const struct option longopts[] = {
DistroBaker 660347
 		{"check-root", no_argument, NULL, 'c'},
DistroBaker 660347
 		{"single-shot", no_argument, NULL, 's'},
DistroBaker 660347
 		{"omit-pid", required_argument, NULL, 'o'},
DistroBaker 660347
 		{"separator", required_argument, NULL, 'S'},
DistroBaker 660347
+		{"with-workers", no_argument, NULL, 'w'},
DistroBaker 660347
 		{"help", no_argument, NULL, 'h'},
DistroBaker 660347
 		{"version", no_argument, NULL, 'V'},
DistroBaker 660347
 		{NULL, 0, NULL, 0}
DistroBaker 660347
@@ -325,6 +327,9 @@ int main (int argc, char **argv)
DistroBaker 660347
 		case 'x':
DistroBaker 660347
 			opt_scripts_too = 1;
DistroBaker 660347
 			break;
DistroBaker 660347
+		case 'w':
DistroBaker 660347
+			opt_with_workers = 1;
DistroBaker 660347
+			break;
DistroBaker 660347
 		case 'c':
DistroBaker 660347
 			if (geteuid() == 0) {
DistroBaker 660347
 				opt_rootdir_check = 1;
DistroBaker 660347
@@ -359,6 +364,8 @@ int main (int argc, char **argv)
DistroBaker 660347
 
DistroBaker 660347
 		program = argv[optind++];
DistroBaker 660347
 
DistroBaker 660347
+		if (*program == '\0') continue;
DistroBaker 660347
+
DistroBaker 660347
 		select_procs();	/* get the list of matching processes */
DistroBaker 660347
 
DistroBaker 660347
 		if (proc_count) {