From 34a9899d1156f15de106b42250aa78d411c685e6 Mon Sep 17 00:00:00 2001 From: Leah Neukirchen Date: Fri, 3 Apr 2020 20:13:18 +0200 Subject: add search by numeric pid --- px.c | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/px.c b/px.c index 877baee..bf74d51 100644 --- a/px.c +++ b/px.c @@ -9,6 +9,7 @@ #include #include +#include #include #include #include @@ -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++; -- cgit 1.4.1