diff options
-rw-r--r-- | usr.bin/pkill/pkill.1 | 13 | ||||
-rw-r--r-- | usr.bin/pkill/pkill.c | 12 |
2 files changed, 14 insertions, 11 deletions
diff --git a/usr.bin/pkill/pkill.1 b/usr.bin/pkill/pkill.1 index 566f3a8c022..ec3bcd5be9f 100644 --- a/usr.bin/pkill/pkill.1 +++ b/usr.bin/pkill/pkill.1 @@ -1,4 +1,4 @@ -.\" $OpenBSD: pkill.1,v 1.16 2010/09/29 07:44:56 jmc Exp $ +.\" $OpenBSD: pkill.1,v 1.17 2012/01/17 04:27:20 lum Exp $ .\" $NetBSD: pkill.1,v 1.8 2003/02/14 15:59:18 grant Exp $ .\" .\" Copyright (c) 2002 The NetBSD Foundation, Inc. @@ -28,7 +28,7 @@ .\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE .\" POSSIBILITY OF SUCH DAMAGE. .\" -.Dd $Mdocdate: September 29 2010 $ +.Dd $Mdocdate: January 17 2012 $ .Dt PKILL 1 .Os .Sh NAME @@ -48,7 +48,7 @@ .Op Ar pattern ... .Nm pkill .Op Fl Ar signal -.Op Fl fnovx +.Op Fl flnovx .Op Fl G Ar gid .Op Fl g Ar pgrp .Op Fl P Ar ppid @@ -99,10 +99,9 @@ Print the process name in addition to the process ID for each matching process. If used in conjunction with .Fl f , -print the process ID and the full argument list for each matching process. -This option can only be used with the -.Nm pgrep -command. +print the process ID and the full argument list for each matching process +.Pf ( Nm pgrep +only). .It Fl n Match only the most recently created (newest) process, if any. Cannot be used in conjunction with diff --git a/usr.bin/pkill/pkill.c b/usr.bin/pkill/pkill.c index cfab3c7c211..89f67223eff 100644 --- a/usr.bin/pkill/pkill.c +++ b/usr.bin/pkill/pkill.c @@ -1,4 +1,4 @@ -/* $OpenBSD: pkill.c,v 1.19 2011/04/10 03:20:59 guenther Exp $ */ +/* $OpenBSD: pkill.c,v 1.20 2012/01/17 04:27:20 lum Exp $ */ /* $NetBSD: pkill.c,v 1.5 2002/10/27 11:49:34 kleink Exp $ */ /*- @@ -112,6 +112,7 @@ main(int argc, char **argv) char buf[_POSIX2_LINE_MAX], *mstr, **pargv, *p, *q; int i, j, ch, bestidx, rv, criteria; int (*action)(struct kinfo_proc *, int); + int did_action; struct kinfo_proc *kp; struct list *li; u_int32_t bestsec, bestusec; @@ -176,8 +177,6 @@ main(int argc, char **argv) criteria = 1; break; case 'l': - if (!pgrep) - usage(); longfmt = 1; break; case 'n': @@ -392,11 +391,16 @@ main(int argc, char **argv) /* * Take the appropriate action for each matched process, if any. */ + did_action = 0; rv = STATUS_NOMATCH; for (i = 0, j = 0, kp = plist; i < nproc; i++, kp++) { if ((kp->p_flag & P_SYSTEM) != 0 || kp->p_pid == mypid) continue; if (selected[i]) { + if (longfmt && !pgrep) { + did_action = 1; + printf("%d %s\n", (int)kp->p_pid, kp->p_comm); + } if (inverse) continue; } else if (!inverse) @@ -421,7 +425,7 @@ usage(void) if (pgrep) ustr = "[-flnovx] [-d delim]"; else - ustr = "[-signal] [-fnovx]"; + ustr = "[-signal] [-flnovx]"; 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); |