From 571652e41dc01b73c157a176ad2cd60db08f9396 Mon Sep 17 00:00:00 2001 From: gad Date: Fri, 26 Mar 2004 01:43:19 +0000 Subject: Add a debugging option, as I don't understand something that I'm seeing. (this is a probably temporary option, and is not to be documented) --- usr.bin/pkill/pkill.c | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) (limited to 'usr.bin/pkill') diff --git a/usr.bin/pkill/pkill.c b/usr.bin/pkill/pkill.c index 0e36c25..19eb910 100644 --- a/usr.bin/pkill/pkill.c +++ b/usr.bin/pkill/pkill.c @@ -125,6 +125,7 @@ main(int argc, char **argv) extern int optind; char buf[_POSIX2_LINE_MAX], *mstr, **pargv, *p, *q; const char *execf, *coref, *swapf; + int debug_opt; int i, ch, bestidx, rv, criteria, drop_privs; size_t jsz; void (*action)(struct kinfo_proc *); @@ -170,10 +171,14 @@ main(int argc, char **argv) #endif criteria = 0; + debug_opt = 0; drop_privs = 0; - while ((ch = getopt(argc, argv, "G:M:N:P:U:d:fg:lns:t:u:vx")) != -1) + while ((ch = getopt(argc, argv, "DG:M:N:P:U:d:fg:lns:t:u:vx")) != -1) switch (ch) { + case 'D': + debug_opt++; + break; case 'G': makelist(&rgidlist, LT_GROUP, optarg); criteria = 1; @@ -285,8 +290,12 @@ main(int argc, char **argv) } for (i = 0, kp = plist; i < nproc; i++, kp++) { - if ((kp->ki_flag & P_SYSTEM) != 0) + if ((kp->ki_flag & P_SYSTEM) != 0) { + if (debug_opt > 0) + printf("* Skipped %5d %3d %s\n", + kp->ki_pid, kp->ki_uid, kp->ki_comm); continue; + } if (matchargs) { if ((pargv = kvm_getargv(kd, kp, 0)) == NULL) @@ -318,6 +327,13 @@ main(int argc, char **argv) regerror(rv, ®, buf, sizeof(buf)); errx(STATUS_ERROR, "regexec(): %s", buf); } + if (debug_opt > 1) { + const char *rv_res = "NoMatch"; + if (selected[i]) + rv_res = "Matched"; + printf("* %s %5d %3d %s\n", rv_res, + kp->ki_pid, kp->ki_uid, mstr); + } } regfree(®); -- cgit v1.1