diff options
author | gad <gad@FreeBSD.org> | 2004-03-26 01:43:19 +0000 |
---|---|---|
committer | gad <gad@FreeBSD.org> | 2004-03-26 01:43:19 +0000 |
commit | 571652e41dc01b73c157a176ad2cd60db08f9396 (patch) | |
tree | 3ef196dd5f1044a6dd765f18d66be8cd63f7fef7 /usr.bin/pkill | |
parent | 15a643c5a91516a2e6a73e691a2b5507f21b9d38 (diff) | |
download | FreeBSD-src-571652e41dc01b73c157a176ad2cd60db08f9396.zip FreeBSD-src-571652e41dc01b73c157a176ad2cd60db08f9396.tar.gz |
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)
Diffstat (limited to 'usr.bin/pkill')
-rw-r--r-- | usr.bin/pkill/pkill.c | 20 |
1 files changed, 18 insertions, 2 deletions
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(®); |