diff options
author | Garance A Drosehn <gad@FreeBSD.org> | 2004-03-26 01:43:19 +0000 |
---|---|---|
committer | Garance A Drosehn <gad@FreeBSD.org> | 2004-03-26 01:43:19 +0000 |
commit | c44047c7a85e3332720c007fe653a8d7cf3e4c64 (patch) | |
tree | 3ef196dd5f1044a6dd765f18d66be8cd63f7fef7 /usr.bin/pkill | |
parent | 5def7269c2f291b22e2d41a1101dabe4eefa9188 (diff) | |
download | src-c44047c7a85e3332720c007fe653a8d7cf3e4c64.tar.gz src-c44047c7a85e3332720c007fe653a8d7cf3e4c64.zip |
Notes
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 0e36c25ed855..19eb910533d7 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(®); |