about summary refs log tree commit diff
diff options
context:
space:
mode:
authorLeah Neukirchen <leah@vuxu.org>2020-04-03 20:13:18 +0200
committerLeah Neukirchen <leah@vuxu.org>2020-04-03 20:13:18 +0200
commit34a9899d1156f15de106b42250aa78d411c685e6 (patch)
tree79c2f0e4e072132aa993148a48f1327e3616d1b2
parent8890ca1e25f649965ff3dd4643b70ff2c3848f18 (diff)
downloadpx-34a9899d1156f15de106b42250aa78d411c685e6.tar.gz
px-34a9899d1156f15de106b42250aa78d411c685e6.tar.xz
px-34a9899d1156f15de106b42250aa78d411c685e6.zip
add search by numeric pid
-rw-r--r--px.c13
1 files changed, 12 insertions, 1 deletions
diff --git a/px.c b/px.c
index 877baee..bf74d51 100644
--- a/px.c
+++ b/px.c
@@ -9,6 +9,7 @@
 #include <sys/auxv.h>
 #include <sys/sysinfo.h>
 
+#include <ctype.h>
 #include <stdint.h>
 #include <stdio.h>
 #include <stdlib.h>
@@ -75,9 +76,19 @@ main(int argc, char *argv[])
 		proc_t *p = *result;
 
 		if (argc > 1) {
-			for (int i = 1; i < argc; i++)
+			for (int i = 1; i < argc; i++) {
+				for (size_t j = 0; j < strlen(argv[i]); j++) {
+					if (!isdigit(argv[i][j]))
+						goto word;
+				}
+				if (p->tid == atoi(argv[i]))
+					goto match;
+				else
+					continue;
+word:
 				if (strstr(p->cmd, argv[i]))
 					goto match;
+			}
 			continue;
 match:
 			matched++;