summaryrefslogtreecommitdiffstats
path: root/usr.bin/killall
diff options
context:
space:
mode:
authordelphij <delphij@FreeBSD.org>2012-06-27 00:50:25 +0000
committerdelphij <delphij@FreeBSD.org>2012-06-27 00:50:25 +0000
commitdb1afde94a4a66209f20da8cac3962631327d4c7 (patch)
treed362cfbed9e6340eef884481830baf179930cad2 /usr.bin/killall
parent922d40fed4b7f6bb0aafe327600825f9680ce0e7 (diff)
downloadFreeBSD-src-db1afde94a4a66209f20da8cac3962631327d4c7.zip
FreeBSD-src-db1afde94a4a66209f20da8cac3962631327d4c7.tar.gz
Add a -I flag which requests confirmation before action, like what is done
in pkill(1). MFC after: 2 weeks
Diffstat (limited to 'usr.bin/killall')
-rw-r--r--usr.bin/killall/killall.16
-rw-r--r--usr.bin/killall/killall.c19
2 files changed, 22 insertions, 3 deletions
diff --git a/usr.bin/killall/killall.1 b/usr.bin/killall/killall.1
index 4529831..7beaadb 100644
--- a/usr.bin/killall/killall.1
+++ b/usr.bin/killall/killall.1
@@ -24,7 +24,7 @@
.\"
.\" $FreeBSD$
.\"
-.Dd December 25, 2009
+.Dd June 27, 2012
.Dt KILLALL 1
.Os
.Sh NAME
@@ -34,6 +34,7 @@
.Nm
.Op Fl delmsvz
.Op Fl help
+.Op Fl I
.Op Fl j Ar jail
.Op Fl u Ar user
.Op Fl t Ar tty
@@ -71,6 +72,9 @@ processes specified with the
option.
.It Fl help
Give a help on the command usage and exit.
+.It Fl I
+Request confirmation before attempting to signal each
+process.
.It Fl l
List the names of the available signals and exit, like in
.Xr kill 1 .
diff --git a/usr.bin/killall/killall.c b/usr.bin/killall/killall.c
index 28496a0..89db399 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] [-j jail]\n");
+ fprintf(stderr, "usage: killall [-delmsvz] [-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");
@@ -95,8 +95,9 @@ main(int ac, char **av)
struct passwd *pw;
regex_t rgx;
regmatch_t pmatch;
- int i, j;
+ int i, j, ch;
char buf[256];
+ char first;
char *user = NULL;
char *tty = NULL;
char *cmd = NULL;
@@ -104,6 +105,7 @@ main(int ac, char **av)
int sflag = 0;
int dflag = 0;
int eflag = 0;
+ int Iflag = 0;
int jflag = 0;
int mflag = 0;
int zflag = 0;
@@ -141,6 +143,9 @@ main(int ac, char **av)
if (**av == '-') {
++*av;
switch (**av) {
+ case 'I':
+ Iflag = 1;
+ break;
case 'j':
++*av;
if (**av == '\0') {
@@ -382,6 +387,16 @@ main(int ac, char **av)
if (matched)
break;
}
+ if (matched != 0 && Iflag) {
+ printf("Send signal %d to %s (pid %d uid %d)? ",
+ sig, thiscmd, thispid, thisuid);
+ fflush(stdout);
+ first = ch = getchar();
+ while (ch != '\n' && ch != EOF)
+ ch = getchar();
+ if (first != 'y' && first != 'Y')
+ matched = 0;
+ }
if (matched == 0)
continue;
if (dflag)
OpenPOWER on IntegriCloud