From owner-freebsd-bugs Wed Sep 12 17:10:12 2001 Delivered-To: freebsd-bugs@hub.freebsd.org Received: from freefall.freebsd.org (freefall.freebsd.org [216.136.204.21]) by hub.freebsd.org (Postfix) with ESMTP id 9884637B40B for ; Wed, 12 Sep 2001 17:10:00 -0700 (PDT) Received: (from gnats@localhost) by freefall.freebsd.org (8.11.4/8.11.4) id f8D0A0L21797; Wed, 12 Sep 2001 17:10:00 -0700 (PDT) (envelope-from gnats) Received: from hand.dotat.at (host217-35-41-52.in-addr.btopenworld.com [217.35.41.52]) by hub.freebsd.org (Postfix) with ESMTP id 90AC237B405 for ; Wed, 12 Sep 2001 17:02:06 -0700 (PDT) Received: from fanf by hand.dotat.at with local (Exim 3.33 #16) id 15hKt4-0001d7-00 for FreeBSD-gnats-submit@freebsd.org; Thu, 13 Sep 2001 01:01:50 +0000 Message-Id: Date: Thu, 13 Sep 2001 01:01:50 +0000 From: Tony Finch Reply-To: Tony Finch To: FreeBSD-gnats-submit@freebsd.org X-Send-Pr-Version: 3.113 Subject: bin/30542: [PATCH] add -q option to shut up killall Sender: owner-freebsd-bugs@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.org >Number: 30542 >Category: bin >Synopsis: [PATCH] add -q option to shut up killall >Confidential: no >Severity: non-critical >Priority: low >Responsible: freebsd-bugs >State: open >Quarter: >Keywords: >Date-Required: >Class: change-request >Submitter-Id: current-users >Arrival-Date: Wed Sep 12 17:10:00 PDT 2001 >Closed-Date: >Last-Modified: >Originator: Tony Finch >Release: FreeBSD 4.4-RC i386 >Organization: dotat labs >Environment: System: FreeBSD hand.dotat.at 4.4-RC FreeBSD 4.4-RC #4: Sat Sep 1 19:06:27 GMT 2001 fanf@hand.dotat.at:/FreeBSD/obj/FreeBSD/releng4/sys/SHARP i386 >Description: Somewhere (can't remember where) I saw some code that did a `killall >/dev/null 2>&1` which made me think there should be a -q option. This patch also happens to have some strlcpy pedantry in it. >How-To-Repeat: >Fix: Index: usr.bin/killall/killall.1 =================================================================== RCS file: /home/ncvs/src/usr.bin/killall/killall.1,v retrieving revision 1.11.2.7 diff -u -r1.11.2.7 killall.1 --- usr.bin/killall/killall.1 2001/08/16 13:16:53 1.11.2.7 +++ usr.bin/killall/killall.1 2001/08/28 22:23:14 @@ -33,6 +33,7 @@ .Sh SYNOPSIS .Nm .Op Fl d | v +.Op Fl q .Op Fl h | ?\& .Op Fl help .Op Fl l @@ -59,6 +60,8 @@ .Pp The options are as follows: .Bl -tag -width 10n -offset indent +.It Fl q +Do not print an error message if no matching processes are found. .It Fl d | v Be more verbose about what will be done. For a single .Fl d Index: usr.bin/killall/killall.c =================================================================== RCS file: /home/ncvs/src/usr.bin/killall/killall.c,v retrieving revision 1.5.2.4 diff -u -r1.5.2.4 killall.c --- usr.bin/killall/killall.c 2001/05/19 19:22:49 1.5.2.4 +++ usr.bin/killall/killall.c 2001/08/28 22:23:14 @@ -62,8 +62,7 @@ static char buf[80]; char *s; - strncpy(buf, str, sizeof(buf)); - buf[sizeof(buf) - 1] = '\0'; + strlcpy(buf, str, sizeof(buf)); for (s = buf; *s; s++) *s = toupper(*s); return buf; @@ -109,6 +108,7 @@ char *user = NULL; char *tty = NULL; char *cmd = NULL; + int qflag = 0; int vflag = 0; int sflag = 0; int dflag = 0; @@ -168,6 +168,9 @@ case 'v': vflag++; break; + case 'q': + qflag++; + break; case 's': sflag++; break; @@ -362,7 +365,7 @@ } } } - if (killed == 0) { + if (!qflag && killed == 0) { fprintf(stderr, "No matching processes %swere found\n", getuid() != 0 ? "belonging to you " : ""); errors = 1; >Release-Note: >Audit-Trail: >Unformatted: To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-bugs" in the body of the message