From nobody@FreeBSD.org  Thu Feb  4 17:34:54 2010
Return-Path: <nobody@FreeBSD.org>
Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34])
	by hub.freebsd.org (Postfix) with ESMTP id CC6781065679
	for <freebsd-gnats-submit@FreeBSD.org>; 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 <freebsd-gnats-submit@FreeBSD.org>; 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 <freebsd-gnats-submit@FreeBSD.org>; 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 <eitanadlerlist@gmail.com>
To: freebsd-gnats-submit@FreeBSD.org
Subject: [patch] Add verbose option to pkill
X-Send-Pr-Version: www-3.1
X-GNATS-Notify:

>Number:         143558
>Category:       bin
>Synopsis:       [patch] Add verbose option to pkill(1)
>Confidential:   no
>Severity:       non-critical
>Priority:       medium
>Responsible:    brian
>State:          closed
>Quarter:        
>Keywords:       
>Date-Required:  
>Class:          change-request
>Submitter-Id:   current-users
>Arrival-Date:   Thu Feb 04 17:40:01 UTC 2010
>Closed-Date:    Sun Jul 11 22:02:28 UTC 2010
>Last-Modified:  Sun Jul 11 22:02:28 UTC 2010
>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:

From: Eitan Adler <eitanadlerlist@gmail.com>
To: bug-followup@freebsd.org, eitanadlerlist@gmail.com
Cc:  
Subject: Re: bin/143558: [patch] Add verbose option to pkill(1)
Date: Sat, 27 Feb 2010 20:48:55 +0200

 Minor fix to my patch:
 
 My first patch had
 +	if (!didAction && !pgrep)
 which I changed to
 +	if (!didAction && !pgrep && longfmt)
 when I realized that the message that nothing happened would always be
 shown if -l was not specified
 
 
 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 && longfmt)
 +	{
 +		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"

From: Eitan Adler <eitanadlerlist@gmail.com>
To: bug-followup@freebsd.org, eitanadlerlist@gmail.com
Cc:  
Subject: Re: bin/143558: [patch] Add verbose option to pkill(1)
Date: Wed, 3 Mar 2010 13:12:59 +0200

 Two updates
 1) remove useless change to getopt parameters
 2) pgrep -l no longer prints out extra kill information
 
 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)
 @@ -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 && !pgrep)
 +			{
 +				didAction = 1;
 +				printf("kill -%d %d\n",signum,kp->ki_pid);
 +			}
  			if (inverse)
  				continue;
  		} else if (!inverse)
  			continue;
  		rv |= (*action)(kp);
  	}
 +	if (!didAction && !pgrep && longfmt)
 +	{
 +		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"

From: Eitan Adler <lists@eitanadler.com>
To: bug-followup@freebsd.org, eitanadlerlist@gmail.com
Cc:  
Subject: Re: bin/143558: [patch] Add verbose option to pkill(1)
Date: Thu, 10 Jun 2010 23:43:05 +0300

 Changing stdout to stderr.....
 
 Index: pkill.1
 ===================================================================
 --- pkill.1	(revision 208656)
 +++ 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 208656)
 +++ pkill.c	(working copy)
 @@ -246,8 +246,6 @@
  			criteria = 1;
  			break;
  		case 'l':
 -			if (!pgrep)
 -				usage();
  			longfmt = 1;
  			break;
  		case 'n':
 @@ -529,16 +527,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 && !pgrep)
 +			{
 +				didAction = 1;
 +				printf("kill -%d %d\n",signum,kp->ki_pid);
 +			}
  			if (inverse)
  				continue;
  		} else if (!inverse)
  			continue;
  		rv |= (*action)(kp);
  	}
 +	if (!didAction && !pgrep && longfmt)
 +	{
 +		fprintf(stderr,"No matching processes belonging to you were found\n");
 +	}
 
  	exit(rv ? STATUS_MATCH : STATUS_NOMATCH);
  }
 @@ -551,7 +559,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"
 
 
 -- 
 Eitan Adler
State-Changed-From-To: open->patched 
State-Changed-By: brian 
State-Changed-When: Sun Jun 20 08:46:39 UTC 2010 
State-Changed-Why:  
Submitted to head (r209363) with a few wording tweaks and style(9) fixes. 
I'll MFC after 3 weeks. 

http://www.freebsd.org/cgi/query-pr.cgi?pr=143558 

From: dfilter@FreeBSD.ORG (dfilter service)
To: bug-followup@FreeBSD.org
Cc:  
Subject: Re: bin/143558: commit references a PR
Date: Sun, 20 Jun 2010 08:48:40 +0000 (UTC)

 Author: brian
 Date: Sun Jun 20 08:48:30 2010
 New Revision: 209363
 URL: http://svn.freebsd.org/changeset/base/209363
 
 Log:
   Recognise the -l switch with pkill - list kill command(s) used.
   
   PR:		143558
   Submitted by:	eitanadlerlist at gmail dot com
   MFC after:	3 weeks
 
 Modified:
   head/bin/pkill/pkill.1
   head/bin/pkill/pkill.c
 
 Modified: head/bin/pkill/pkill.1
 ==============================================================================
 --- head/bin/pkill/pkill.1	Sun Jun 20 08:27:03 2010	(r209362)
 +++ head/bin/pkill/pkill.1	Sun Jun 20 08:48:30 2010	(r209363)
 @@ -156,14 +156,16 @@ The value
  matches processes not in jail.
  .It Fl l
  Long output.
 -Print the process name in addition to the process ID for each matching
 +For
 +.Nm pgrep ,
 +print the process name in addition to the process ID for each matching
  process.
  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.
 +For
 +.Nm pkill ,
 +display the kill command used for each process killed.
  .It Fl n
  Select only the newest (most recently started) of the matching processes.
  .It Fl o
 
 Modified: head/bin/pkill/pkill.c
 ==============================================================================
 --- head/bin/pkill/pkill.c	Sun Jun 20 08:27:03 2010	(r209362)
 +++ head/bin/pkill/pkill.c	Sun Jun 20 08:48:30 2010	(r209363)
 @@ -128,7 +128,7 @@ main(int argc, char **argv)
  {
  	char buf[_POSIX2_LINE_MAX], *mstr, **pargv, *p, *q, *pidfile;
  	const char *execf, *coref;
 -	int ancestors, debug_opt;
 +	int ancestors, debug_opt, did_action;
  	int i, ch, bestidx, rv, criteria, pidfromfile, pidfilelock;
  	size_t jsz;
  	int (*action)(const struct kinfo_proc *);
 @@ -242,8 +242,6 @@ main(int argc, char **argv)
  			criteria = 1;
  			break;
  		case 'l':
 -			if (!pgrep)
 -				usage();
  			longfmt = 1;
  			break;
  		case 'n':
 @@ -530,16 +528,24 @@ main(int argc, char **argv)
  	/*
  	 * Take the appropriate action for each matched process, if any.
  	 */
 +	did_action = 0;
  	for (i = 0, rv = 0, kp = plist; i < nproc; i++, kp++) {
  		if (PSKIP(kp))
  			continue;
  		if (selected[i]) {
 +			if (longfmt && !pgrep) {
 +				did_action = 1;
 +				printf("kill -%d %d\n", signum, kp->ki_pid);
 +			}
  			if (inverse)
  				continue;
  		} else if (!inverse)
  			continue;
  		rv |= (*action)(kp);
  	}
 +	if (!did_action && !pgrep && longfmt)
 +		fprintf(stderr,
 +		    "No matching processes belonging to you were found\n");
  
  	exit(rv ? STATUS_MATCH : STATUS_NOMATCH);
  }
 @@ -552,7 +558,7 @@ usage(void)
  	if (pgrep)
  		ustr = "[-LSfilnoqvx] [-d delim]";
  	else
 -		ustr = "[-signal] [-ILfinovx]";
 +		ustr = "[-signal] [-ILfilnovx]";
  
  	fprintf(stderr,
  		"usage: %s %s [-F pidfile] [-G gid] [-M core] [-N system]\n"
 _______________________________________________
 svn-src-all@freebsd.org mailing list
 http://lists.freebsd.org/mailman/listinfo/svn-src-all
 To unsubscribe, send any mail to "svn-src-all-unsubscribe@freebsd.org"
 
Responsible-Changed-From-To: freebsd-bugs->brian 
Responsible-Changed-By: brian 
Responsible-Changed-When: Sun Jun 20 19:56:30 UTC 2010 
Responsible-Changed-Why:  
Take 

http://www.freebsd.org/cgi/query-pr.cgi?pr=143558 

From: dfilter@FreeBSD.ORG (dfilter service)
To: bug-followup@FreeBSD.org
Cc:  
Subject: Re: bin/143558: commit references a PR
Date: Sun, 11 Jul 2010 21:55:30 +0000 (UTC)

 Author: brian
 Date: Sun Jul 11 21:50:05 2010
 New Revision: 209912
 URL: http://svn.freebsd.org/changeset/base/209912
 
 Log:
   MFC r209363: Recognise the -l switch in pkill.
   
   PR:		143558
   Submitted by:	eitanadlerlist at gmail dot com
 
 Modified:
   stable/8/bin/pkill/pkill.1
   stable/8/bin/pkill/pkill.c
 Directory Properties:
   stable/8/bin/pkill/   (props changed)
 
 Modified: stable/8/bin/pkill/pkill.1
 ==============================================================================
 --- stable/8/bin/pkill/pkill.1	Sun Jul 11 21:47:38 2010	(r209911)
 +++ stable/8/bin/pkill/pkill.1	Sun Jul 11 21:50:05 2010	(r209912)
 @@ -163,14 +163,16 @@ The value
  matches processes not in jail.
  .It Fl l
  Long output.
 -Print the process name in addition to the process ID for each matching
 +For
 +.Nm pgrep ,
 +print the process name in addition to the process ID for each matching
  process.
  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.
 +For
 +.Nm pkill ,
 +display the kill command used for each process killed.
  .It Fl n
  Select only the newest (most recently started) of the matching processes.
  .It Fl o
 
 Modified: stable/8/bin/pkill/pkill.c
 ==============================================================================
 --- stable/8/bin/pkill/pkill.c	Sun Jul 11 21:47:38 2010	(r209911)
 +++ stable/8/bin/pkill/pkill.c	Sun Jul 11 21:50:05 2010	(r209912)
 @@ -133,7 +133,7 @@ main(int argc, char **argv)
  {
  	char buf[_POSIX2_LINE_MAX], *mstr, **pargv, *p, *q, *pidfile;
  	const char *execf, *coref;
 -	int ancestors, debug_opt;
 +	int ancestors, debug_opt, did_action;
  	int i, ch, bestidx, rv, criteria, pidfromfile, pidfilelock;
  	size_t jsz;
  	int (*action)(const struct kinfo_proc *);
 @@ -246,8 +246,6 @@ main(int argc, char **argv)
  			criteria = 1;
  			break;
  		case 'l':
 -			if (!pgrep)
 -				usage();
  			longfmt = 1;
  			break;
  		case 'n':
 @@ -529,16 +527,24 @@ main(int argc, char **argv)
  	/*
  	 * Take the appropriate action for each matched process, if any.
  	 */
 +	did_action = 0;
  	for (i = 0, rv = 0, kp = plist; i < nproc; i++, kp++) {
  		if (PSKIP(kp))
  			continue;
  		if (selected[i]) {
 +			if (longfmt && !pgrep) {
 +				did_action = 1;
 +				printf("kill -%d %d\n", signum, kp->ki_pid);
 +			}
  			if (inverse)
  				continue;
  		} else if (!inverse)
  			continue;
  		rv |= (*action)(kp);
  	}
 +	if (!did_action && !pgrep && longfmt)
 +		fprintf(stderr,
 +		    "No matching processes belonging to you were found\n");
  
  	exit(rv ? STATUS_MATCH : STATUS_NOMATCH);
  }
 @@ -551,7 +557,7 @@ usage(void)
  	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"
 _______________________________________________
 svn-src-all@freebsd.org mailing list
 http://lists.freebsd.org/mailman/listinfo/svn-src-all
 To unsubscribe, send any mail to "svn-src-all-unsubscribe@freebsd.org"
 
State-Changed-From-To: patched->closed 
State-Changed-By: brian 
State-Changed-When: Sun Jul 11 22:02:04 UTC 2010 
State-Changed-Why:  
Merged to stable/8, r209912 

http://www.freebsd.org/cgi/query-pr.cgi?pr=143558 
>Unformatted:
