about summary refs log tree commit diff
path: root/px.c
diff options
context:
space:
mode:
Diffstat (limited to 'px.c')
-rw-r--r--px.c28
1 files changed, 15 insertions, 13 deletions
diff --git a/px.c b/px.c
index 6172ecb..aef25c0 100644
--- a/px.c
+++ b/px.c
@@ -22,6 +22,7 @@
 #include <libproc2/stat.h>
 
 int fflag;
+int tflag;
 
 static void
 print_human(intmax_t i)
@@ -109,26 +110,27 @@ main(int argc, char *argv[])
 		exit(2);
 	}
 
+	int matched = 0;
+
+	int c;
+	while ((c = getopt(argc, argv, "tf")) != -1)
+		switch (c) {
+		case 't': tflag = 1; break;
+		case 'f': fflag = 1; break;
+		default:
+			fprintf(stderr,
+			    "Usage: %s [-f] [PATTERN...]\n", argv[0]);
+			exit(2);
+		}
+
 	struct pids_fetch *reap = procps_pids_reap(Pids_info,
-	    PIDS_FETCH_TASKS_ONLY);
+	    tflag == 0 ? PIDS_FETCH_TASKS_ONLY : PIDS_FETCH_THREADS_TOO);
 	if (!reap) {
 		fprintf(stderr, "failed to run procps_pids_reap: %s\n",
 		    strerror(errno));
 		exit(2);
 	}
 
-	int matched = 0;
-
-	int c;
-        while ((c = getopt(argc, argv, "f")) != -1)
-                switch (c) {
-		case 'f': fflag = 1; break;
-                default:
-                        fprintf(stderr,
-			    "Usage: %s [-f] [PATTERN...]\n", argv[0]);
-                        exit(2);
-                }
-
 	int total_procs = reap->counts->total;
 	for (int i = 0; i < total_procs; i++) {
 #define PIDS_GETCHR(e) PIDS_VAL(EU_ ## e, s_ch, reap->stacks[i], Pids_info)