version 1.19, 2011/04/10 03:20:59 |
version 1.20, 2012/01/17 04:27:20 |
|
|
char buf[_POSIX2_LINE_MAX], *mstr, **pargv, *p, *q; |
char buf[_POSIX2_LINE_MAX], *mstr, **pargv, *p, *q; |
int i, j, ch, bestidx, rv, criteria; |
int i, j, ch, bestidx, rv, criteria; |
int (*action)(struct kinfo_proc *, int); |
int (*action)(struct kinfo_proc *, int); |
|
int did_action; |
struct kinfo_proc *kp; |
struct kinfo_proc *kp; |
struct list *li; |
struct list *li; |
u_int32_t bestsec, bestusec; |
u_int32_t bestsec, bestusec; |
|
|
criteria = 1; |
criteria = 1; |
break; |
break; |
case 'l': |
case 'l': |
if (!pgrep) |
|
usage(); |
|
longfmt = 1; |
longfmt = 1; |
break; |
break; |
case 'n': |
case 'n': |
|
|
/* |
/* |
* Take the appropriate action for each matched process, if any. |
* Take the appropriate action for each matched process, if any. |
*/ |
*/ |
|
did_action = 0; |
rv = STATUS_NOMATCH; |
rv = STATUS_NOMATCH; |
for (i = 0, j = 0, kp = plist; i < nproc; i++, kp++) { |
for (i = 0, j = 0, kp = plist; i < nproc; i++, kp++) { |
if ((kp->p_flag & P_SYSTEM) != 0 || kp->p_pid == mypid) |
if ((kp->p_flag & P_SYSTEM) != 0 || kp->p_pid == mypid) |
continue; |
continue; |
if (selected[i]) { |
if (selected[i]) { |
|
if (longfmt && !pgrep) { |
|
did_action = 1; |
|
printf("%d %s\n", (int)kp->p_pid, kp->p_comm); |
|
} |
if (inverse) |
if (inverse) |
continue; |
continue; |
} else if (!inverse) |
} else if (!inverse) |
|
|
if (pgrep) |
if (pgrep) |
ustr = "[-flnovx] [-d delim]"; |
ustr = "[-flnovx] [-d delim]"; |
else |
else |
ustr = "[-signal] [-fnovx]"; |
ustr = "[-signal] [-flnovx]"; |
|
|
fprintf(stderr, "usage: %s %s [-G gid] [-g pgrp] [-P ppid] [-s sid] " |
fprintf(stderr, "usage: %s %s [-G gid] [-g pgrp] [-P ppid] [-s sid] " |
"[-t tty]\n\t[-U uid] [-u euid] [pattern ...]\n", __progname, ustr); |
"[-t tty]\n\t[-U uid] [-u euid] [pattern ...]\n", __progname, ustr); |