From fdd0a4cf934b0c544c97ceba0888463d2819c2f2 Mon Sep 17 00:00:00 2001 From: mjg Date: Sun, 30 Jun 2013 20:27:31 +0000 Subject: killall: add -q flag to suppress error message when no processes are matched Man-page text provided by wblock. PR: bin/30542 Submitted by: Tony Finch (original version) MFC after: 1 week --- usr.bin/killall/killall.1 | 4 +++- usr.bin/killall/killall.c | 11 ++++++++--- 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/usr.bin/killall/killall.1 b/usr.bin/killall/killall.1 index 7beaadb..be813f7 100644 --- a/usr.bin/killall/killall.1 +++ b/usr.bin/killall/killall.1 @@ -24,7 +24,7 @@ .\" .\" $FreeBSD$ .\" -.Dd June 27, 2012 +.Dd June 30, 2013 .Dt KILLALL 1 .Os .Sh NAME @@ -110,6 +110,8 @@ the specified Limit potentially matching processes to those matching the specified .Ar procname . +.It Fl q +Suppress error message if no processes are matched. .It Fl z Do not skip zombies. This should not have any effect except to print a few error messages diff --git a/usr.bin/killall/killall.c b/usr.bin/killall/killall.c index 83e829a..dd22a83 100644 --- a/usr.bin/killall/killall.c +++ b/usr.bin/killall/killall.c @@ -53,7 +53,7 @@ static void __dead2 usage(void) { - fprintf(stderr, "usage: killall [-delmsvz] [-help] [-I] [-j jail]\n"); + fprintf(stderr, "usage: killall [-delmsqvz] [-help] [-I] [-j jail]\n"); fprintf(stderr, " [-u user] [-t tty] [-c cmd] [-SIGNAL] [cmd]...\n"); fprintf(stderr, "At least one option or argument to specify processes must be given.\n"); @@ -101,6 +101,7 @@ main(int ac, char **av) char *user = NULL; char *tty = NULL; char *cmd = NULL; + int qflag = 0; int vflag = 0; int sflag = 0; int dflag = 0; @@ -191,6 +192,9 @@ main(int ac, char **av) errx(1, "must specify procname"); cmd = *av; break; + case 'q': + qflag++; + break; case 'v': vflag++; break; @@ -417,8 +421,9 @@ main(int ac, char **av) } } if (killed == 0) { - fprintf(stderr, "No matching processes %swere found\n", - getuid() != 0 ? "belonging to you " : ""); + if (!qflag) + fprintf(stderr, "No matching processes %swere found\n", + getuid() != 0 ? "belonging to you " : ""); errors = 1; } exit(errors); -- cgit v1.1