Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/usr.bin/pkill Add a -q option for pgrep to not print anythin...
details: https://anonhg.NetBSD.org/src/rev/91af1f7910ee
branches: trunk
changeset: 372158:91af1f7910ee
user: simonb <simonb%NetBSD.org@localhost>
date: Sat Oct 29 08:17:16 2022 +0000
description:
Add a -q option for pgrep to not print anything; similar to grep -q.
diffstat:
usr.bin/pkill/pkill.1 | 13 ++++++++++---
usr.bin/pkill/pkill.c | 17 +++++++++++++----
2 files changed, 23 insertions(+), 7 deletions(-)
diffs (107 lines):
diff -r 42b8bc04fe5b -r 91af1f7910ee usr.bin/pkill/pkill.1
--- a/usr.bin/pkill/pkill.1 Sat Oct 29 07:32:54 2022 +0000
+++ b/usr.bin/pkill/pkill.1 Sat Oct 29 08:17:16 2022 +0000
@@ -1,4 +1,4 @@
-.\" $NetBSD: pkill.1,v 1.31 2022/01/01 08:34:35 msaitoh Exp $
+.\" $NetBSD: pkill.1,v 1.32 2022/10/29 08:17:16 simonb Exp $
.\"
.\" Copyright (c) 2002 The NetBSD Foundation, Inc.
.\" All rights reserved.
@@ -27,7 +27,7 @@
.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
.\" POSSIBILITY OF SUCH DAMAGE.
.\"
-.Dd December 3, 2018
+.Dd October 29, 2022
.Dt PKILL 1
.Os
.Sh NAME
@@ -37,7 +37,7 @@
.Nd find or signal processes by name
.Sh SYNOPSIS
.Nm pgrep
-.Op Fl filnvx
+.Op Fl filnqvx
.Op Fl d Ar delim
.Op Fl G Ar gid
.Op Fl g Ar pgrp
@@ -179,6 +179,13 @@
.Nm pkill .
.El
.Pp
+The following option is also available for
+.Nm pgrep :
+.Bl -tag -width xxxxxxxx
+.It Fl q
+Quiet; do not write anything to standard output.
+.El
+.Pp
The
.Fl l
flag is also available for
diff -r 42b8bc04fe5b -r 91af1f7910ee usr.bin/pkill/pkill.c
--- a/usr.bin/pkill/pkill.c Sat Oct 29 07:32:54 2022 +0000
+++ b/usr.bin/pkill/pkill.c Sat Oct 29 08:17:16 2022 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: pkill.c,v 1.32 2022/07/02 20:50:26 ad Exp $ */
+/* $NetBSD: pkill.c,v 1.33 2022/10/29 08:17:16 simonb Exp $ */
/*-
* Copyright (c) 2002, 2022 The NetBSD Foundation, Inc.
@@ -31,7 +31,7 @@
#include <sys/cdefs.h>
#ifndef lint
-__RCSID("$NetBSD: pkill.c,v 1.32 2022/07/02 20:50:26 ad Exp $");
+__RCSID("$NetBSD: pkill.c,v 1.33 2022/10/29 08:17:16 simonb Exp $");
#endif /* !lint */
#include <sys/types.h>
@@ -87,6 +87,7 @@
static int signum = SIGTERM;
static int nicenum;
static int newest;
+static int quiet;
static int inverse;
static int longfmt;
static int matchargs;
@@ -181,7 +182,7 @@
} else
usage();
} else {
- while ((ch = getopt(argc, argv, "G:P:U:d:fg:ilns:t:u:vx")) != -1)
+ while ((ch = getopt(argc, argv, "G:P:U:d:fg:ilnqs:t:u:vx")) != -1)
switch (ch) {
case 'G':
makelist(&rgidlist, LT_GROUP, optarg);
@@ -217,6 +218,11 @@
newest = 1;
criteria = 1;
break;
+ case 'q':
+ if (!pgrep)
+ usage();
+ quiet = 1;
+ break;
case 's':
makelist(&sidlist, LT_SID, optarg);
criteria = 1;
@@ -443,7 +449,7 @@
getprogname());
else {
if (pgrep)
- ustr = "[-filnvx] [-d delim]";
+ ustr = "[-filnqvx] [-d delim]";
else
ustr = "[-signal] [-filnvx]";
@@ -514,6 +520,9 @@
{
char **argv;
+ if (quiet)
+ return 1;
+
if (longfmt && matchargs) {
/*
Home |
Main Index |
Thread Index |
Old Index