From owner-svn-src-all@FreeBSD.ORG Wed Jun 27 00:50:25 2012 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id DB3EF1065672; Wed, 27 Jun 2012 00:50:25 +0000 (UTC) (envelope-from delphij@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id ABC858FC0A; Wed, 27 Jun 2012 00:50:25 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.4/8.14.4) with ESMTP id q5R0oPsw071968; Wed, 27 Jun 2012 00:50:25 GMT (envelope-from delphij@svn.freebsd.org) Received: (from delphij@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id q5R0oPas071965; Wed, 27 Jun 2012 00:50:25 GMT (envelope-from delphij@svn.freebsd.org) Message-Id: <201206270050.q5R0oPas071965@svn.freebsd.org> From: Xin LI Date: Wed, 27 Jun 2012 00:50:25 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r237618 - head/usr.bin/killall X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 27 Jun 2012 00:50:26 -0000 Author: delphij Date: Wed Jun 27 00:50:25 2012 New Revision: 237618 URL: http://svn.freebsd.org/changeset/base/237618 Log: Add a -I flag which requests confirmation before action, like what is done in pkill(1). MFC after: 2 weeks Modified: head/usr.bin/killall/killall.1 head/usr.bin/killall/killall.c Modified: head/usr.bin/killall/killall.1 ============================================================================== --- head/usr.bin/killall/killall.1 Wed Jun 27 00:37:22 2012 (r237617) +++ head/usr.bin/killall/killall.1 Wed Jun 27 00:50:25 2012 (r237618) @@ -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 . Modified: head/usr.bin/killall/killall.c ============================================================================== --- head/usr.bin/killall/killall.c Wed Jun 27 00:37:22 2012 (r237617) +++ head/usr.bin/killall/killall.c Wed Jun 27 00:50:25 2012 (r237618) @@ -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)