Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 13 Sep 2001 01:01:50 +0000
From:      Tony Finch <dot@dotat.at>
To:        FreeBSD-gnats-submit@freebsd.org
Subject:   bin/30542: [PATCH] add -q option to shut up killall
Message-ID:  <E15hKt4-0001d7-00@hand.dotat.at>

next in thread | raw e-mail | index | archive | help

>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




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?E15hKt4-0001d7-00>