From owner-freebsd-bugs@FreeBSD.ORG Thu Feb 4 17:40:01 2010 Return-Path: Delivered-To: freebsd-bugs@hub.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id D7D811065693 for ; Thu, 4 Feb 2010 17:40:01 +0000 (UTC) (envelope-from gnats@FreeBSD.org) Received: from freefall.freebsd.org (freefall.freebsd.org [IPv6:2001:4f8:fff6::28]) by mx1.freebsd.org (Postfix) with ESMTP id 9B8EA8FC13 for ; Thu, 4 Feb 2010 17:40:01 +0000 (UTC) Received: from freefall.freebsd.org (localhost [127.0.0.1]) by freefall.freebsd.org (8.14.3/8.14.3) with ESMTP id o14He1XY097406 for ; Thu, 4 Feb 2010 17:40:01 GMT (envelope-from gnats@freefall.freebsd.org) Received: (from gnats@localhost) by freefall.freebsd.org (8.14.3/8.14.3/Submit) id o14He1D4097405; Thu, 4 Feb 2010 17:40:01 GMT (envelope-from gnats) Resent-Date: Thu, 4 Feb 2010 17:40:01 GMT Resent-Message-Id: <201002041740.o14He1D4097405@freefall.freebsd.org> Resent-From: FreeBSD-gnats-submit@FreeBSD.org (GNATS Filer) Resent-To: freebsd-bugs@FreeBSD.org Resent-Reply-To: FreeBSD-gnats-submit@FreeBSD.org, Eitan Adler Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id CC6781065679 for ; Thu, 4 Feb 2010 17:34:54 +0000 (UTC) (envelope-from nobody@FreeBSD.org) Received: from www.freebsd.org (www.freebsd.org [IPv6:2001:4f8:fff6::21]) by mx1.freebsd.org (Postfix) with ESMTP id A44048FC27 for ; Thu, 4 Feb 2010 17:34:54 +0000 (UTC) Received: from www.freebsd.org (localhost [127.0.0.1]) by www.freebsd.org (8.14.3/8.14.3) with ESMTP id o14HYsoP073005 for ; Thu, 4 Feb 2010 17:34:54 GMT (envelope-from nobody@www.freebsd.org) Received: (from nobody@localhost) by www.freebsd.org (8.14.3/8.14.3/Submit) id o14HYs1j073004; Thu, 4 Feb 2010 17:34:54 GMT (envelope-from nobody) Message-Id: <201002041734.o14HYs1j073004@www.freebsd.org> Date: Thu, 4 Feb 2010 17:34:54 GMT From: Eitan Adler To: freebsd-gnats-submit@FreeBSD.org X-Send-Pr-Version: www-3.1 Cc: Subject: bin/143558: [patch] Add verbose option to pkill X-BeenThere: freebsd-bugs@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Bug reports List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 04 Feb 2010 17:40:02 -0000 >Number: 143558 >Category: bin >Synopsis: [patch] Add verbose option to pkill >Confidential: no >Severity: non-critical >Priority: medium >Responsible: freebsd-bugs >State: open >Quarter: >Keywords: >Date-Required: >Class: change-request >Submitter-Id: current-users >Arrival-Date: Thu Feb 04 17:40:01 UTC 2010 >Closed-Date: >Last-Modified: >Originator: Eitan Adler >Release: FreeBSD 8.0 Release Patch 2 >Organization: >Environment: >Description: Allows user to specify -l for pkill to print out which processes were killed if any. >How-To-Repeat: >Fix: Patch attached with submission follows: Index: pkill.1 =================================================================== --- pkill.1 (revision 203347) +++ pkill.1 (working copy) @@ -168,9 +168,9 @@ If used in conjunction with .Fl f , print the process ID and the full argument list for each matching process. -This option can only be used with the -.Nm pgrep -command. +If used in conjunction with the +.Nm pkill +command, it lists the signal sent as well. .It Fl n Select only the newest (most recently started) of the matching processes. .It Fl o Index: pkill.c =================================================================== --- pkill.c (revision 203347) +++ pkill.c (working copy) @@ -182,7 +182,7 @@ pidfilelock = 0; execf = coref = _PATH_DEVNULL; - while ((ch = getopt(argc, argv, "DF:G:ILM:N:P:SU:ad:fg:ij:lnos:t:u:vx")) != -1) + while ((ch = getopt(argc, argv, "DF:G:ILM:N:P:SU:ad:fg:ilj:lnos:t:u:vx")) != -1) switch (ch) { case 'D': debug_opt++; @@ -245,8 +245,6 @@ criteria = 1; break; case 'l': - if (!pgrep) - usage(); longfmt = 1; break; case 'n': @@ -528,16 +526,26 @@ /* * Take the appropriate action for each matched process, if any. */ + int didAction = 0; for (i = 0, rv = 0, kp = plist; i < nproc; i++, kp++) { if (PSKIP(kp)) continue; if (selected[i]) { + if (longfmt) + { + didAction = 1; + printf("kill -%d %d\n",signum,kp->ki_pid); + } if (inverse) continue; } else if (!inverse) continue; rv |= (*action)(kp); } + if (!didAction && !pgrep) + { + printf("No matching processes belonging to you were found\n"); + } exit(rv ? STATUS_MATCH : STATUS_NOMATCH); } @@ -550,7 +558,7 @@ if (pgrep) ustr = "[-LSfilnovx] [-d delim]"; else - ustr = "[-signal] [-ILfinovx]"; + ustr = "[-signal] [-ILfilnovx]"; fprintf(stderr, "usage: %s %s [-F pidfile] [-G gid] [-M core] [-N system]\n" >Release-Note: >Audit-Trail: >Unformatted: