Re: [RFC] [patch] pkill verbose option
At 11:50 AM +0300 4/19/10, Eitan Adler wrote: This has been waiting as a pr for a while - any update if this will be committed? http://www.freebsd.org/cgi/query-pr.cgi?pr=bin/143558 Oops. I think I'm supposed to be looking into that... -- Garance Alistair Drosehn = dros...@rpi.edu Senior Systems Programmer or g...@freebsd.org Rensselaer Polytechnic Institute; Troy, NY; USA ___ freebsd-hackers@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/freebsd-hackers To unsubscribe, send any mail to "freebsd-hackers-unsubscr...@freebsd.org"
Re: [RFC] [patch] pkill verbose option
This has been waiting as a pr for a while - any update if this will be committed? http://www.freebsd.org/cgi/query-pr.cgi?pr=bin/143558 ___ freebsd-hackers@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/freebsd-hackers To unsubscribe, send any mail to "freebsd-hackers-unsubscr...@freebsd.org"
Re: [RFC] [patch] pkill verbose option
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 Content-ID: On Thu, 4 Feb 2010 11:01, jhell@ wrote: On Thu, 4 Feb 2010 05:01, eitanadlerlist@ wrote: This patch hijacks pgrep's -l [cut] This particular section of the patch should probably be left out until its worked over in a way that it does not print the info message if a process has been found and killed already. if (!didAction && !pgrep) { printf("No matching processes belonging to you were found\n"); } Thanks for the re-patch, quick and resourceful... ;) The attached patch is for stable/7 and does not have the above printf for no matching processes. It also cleans up the formatting a little following the rest of the code and adds the -l flag to the usage statement. This is only the patch for pkill itself and not for the manual page. ;-) - -- jhell -BEGIN PGP SIGNATURE- Version: GnuPG v2.0.14 (FreeBSD) iQEcBAEBAgAGBQJLavsEAAoJEJBXh4mJ2FR+WMwH/1FQY4+FV5xLd6Lg2xgjcbG0 ptDjfr5EdIowWeE2EckcmkZGHZa6Z9WL3zcgOHBfJbsm7pchKUoAjzihlk2iW76u yBHknDs0Wysv7g0y2nA5sDmjAzzJV8xF8W7aGps+eRJYp1dSDQh9h5zRLAKqZXQ+ hmc43ZUOTYsOoMdPcHJUm48og5Q7IiVeh4B7T6PeMaFdolwW8wGwJuXjOzRw4+UH A6g+bBctFNrLIxj6eb39oxhIXoDv7unwM+JONJKJvtKWOmbVD22VVYSMeNKSOeqX 9SelPiwdBj9ulJfTuRmrpfuPw/J7CpkrIwKsifPqP3DYuKQ8qLiBO/jRJwLNkpA= =PD/9 -END PGP SIGNATURE-Index: pkill.c === --- pkill.c (revision 193627) +++ 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,10 +526,15 @@ /* * 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) @@ -550,7 +553,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" ___ freebsd-hackers@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/freebsd-hackers To unsubscribe, send any mail to "freebsd-hackers-unsubscr...@freebsd.org"
Re: [RFC] [patch] pkill verbose option
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 On Thu, 4 Feb 2010 07:10, lars.engels@ wrote: On Thu, Feb 04, 2010 at 12:01:26PM +0200, Eitan Adler wrote: This patch hijacks pgrep's -l I'd like to paint the bikeshed with little -p's ;-) If it is a bikeshed then maybe we should make it '-bs' but then again you might just confuse that for 'bullshit'. - -- jhell -BEGIN PGP SIGNATURE- Version: GnuPG v2.0.14 (FreeBSD) iQEcBAEBAgAGBQJLau/6AAoJEJBXh4mJ2FR+wbYIAJ6Aw9iMCsdNDVFxyksDWxXH iJoSDE3MRC7IUCR/y8CpCfJxKVuXmoIALoMZXE1v8b9SOAyaSydnMcOTd7b6bvEg LMh1hC3KsHp84lWgzu2fra9BBSWQXFkeb1vgunWjwYbV1AM2XnTKJ1eGlWvVK2Pt BxovnoZhOStiSolTUPPhSDcRjHhkZ0906PfvbX2/oWv/qFonXt7aI3t0rj5Y4anF +TcmtCFIvxgvu7LwPriO+0M5Ud99bqMX4UZSeLMTukWZ96tS9KTisfxliZmixG0H OrBzo4IudUr6HLGvZDClhT6RJtlheeUv88GbGCXtOJg5tmH+IpsQD0+e8t09uGo= =HFpu -END PGP SIGNATURE- ___ freebsd-hackers@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/freebsd-hackers To unsubscribe, send any mail to "freebsd-hackers-unsubscr...@freebsd.org"
Re: [RFC] [patch] pkill verbose option
On Thu, 4 Feb 2010 05:01, eitanadlerlist@ wrote: This patch hijacks pgrep's -l [cut] This particular section of the patch should probably be left out until its worked over in a way that it does not print the info message if a process has been found and killed already. if (!didAction && !pgrep) { printf("No matching processes belonging to you were found\n"); } Thanks for the re-patch, quick and resourceful... ;) -- jhell ___ freebsd-hackers@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/freebsd-hackers To unsubscribe, send any mail to "freebsd-hackers-unsubscr...@freebsd.org"
Re: [RFC] [patch] pkill verbose option
On Thu, Feb 04, 2010 at 12:01:26PM +0200, Eitan Adler wrote: > This patch hijacks pgrep's -l > I'd like to paint the bikeshed with little -p's ;-) pgpnxCW9VgVDg.pgp Description: PGP signature
Re: [RFC] [patch] pkill verbose option
This patch hijacks pgrep's -l 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); } On Thu, Feb 4, 2010 at 11:24 AM, Jason Spiro wrote: > jhell DataIX.net> writes: > > [snip] > > > > Now pkill -v sleep on my system actually causes my Xserver to exit with a > > unexpected signal 15. > > Yes. "pkill -v sleep" kills all your own processes except for sleep. As > root, > it kills all processes running on your machine except for sleep. > > -V is not a good choice of letter for this option: it's too easy to write > -v > instead by accident. -l (dash-ell), as jhell has suggested elsewhere in > this > thread, would be ideal, since it's lowercase and easy to type. If you > don't > like -l, you could choose to make it -D (for "Debug") instead. > > ___ > freebsd-hackers@freebsd.org mailing list > http://lists.freebsd.org/mailman/listinfo/freebsd-hackers > To unsubscribe, send any mail to "freebsd-hackers-unsubscr...@freebsd.org" > ___ freebsd-hackers@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/freebsd-hackers To unsubscribe, send any mail to "freebsd-hackers-unsubscr...@freebsd.org"
Re: [RFC] [patch] pkill verbose option
jhell DataIX.net> writes: [snip] > > Now pkill -v sleep on my system actually causes my Xserver to exit with a > unexpected signal 15. Yes. "pkill -v sleep" kills all your own processes except for sleep. As root, it kills all processes running on your machine except for sleep. -V is not a good choice of letter for this option: it's too easy to write -v instead by accident. -l (dash-ell), as jhell has suggested elsewhere in this thread, would be ideal, since it's lowercase and easy to type. If you don't like -l, you could choose to make it -D (for "Debug") instead. ___ freebsd-hackers@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/freebsd-hackers To unsubscribe, send any mail to "freebsd-hackers-unsubscr...@freebsd.org"
Re: [RFC] [patch] pkill verbose option
On Wed, 3 Feb 2010 16:17, eitanadlerlist@ wrote: Yeah - I wasn't sure what else to use. Does the -V work as intended? Is this a worthwhile patch? IMHO the biggest problem with unix system commands is the lack of constancy of the flags. Personally I would like to see pkill have this option as '-l' since pgrep uses '-l' for long output I think it would make more sense if the user is already used to what they expect to find in pgrep be also available in pkill. Other than that it works as expected. ;) On Wed, Feb 3, 2010 at 7:58 PM, jhell wrote: On Wed, 3 Feb 2010 12:52, jhell@ wrote: On Wed, 3 Feb 2010 10:00, eitanadlerlist@ wrote: I added an option to pkill which lists what processes it kills and what signal is sent. If no signals are sent it prints out the same message killall does. Unfortunately that patch works but has unintended operation that can be seen with the following. sleep 1000 & pkill sleep No matching processes belonging to you were found [1]+ Terminated: 15 sleep 1 It then kills sleep and still prints no processes belong to you message. Now pkill -v sleep on my system actually causes my Xserver to exit with a unexpected signal 15. Without the patches it works as it should... Overhead endured. Ugh! ignore the pkill -v comment. Should have noticed the -V instead. -- jhell -- jhell ___ freebsd-hackers@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/freebsd-hackers To unsubscribe, send any mail to "freebsd-hackers-unsubscr...@freebsd.org"
Re: [RFC] [patch] pkill verbose option
Yeah - I wasn't sure what else to use. Does the -V work as intended? Is this a worthwhile patch? IMHO the biggest problem with unix system commands is the lack of constancy of the flags. On Wed, Feb 3, 2010 at 7:58 PM, jhell wrote: > > On Wed, 3 Feb 2010 12:52, jhell@ wrote: > >> >> On Wed, 3 Feb 2010 10:00, eitanadlerlist@ wrote: >> >>> I added an option to pkill which lists what processes it kills and what >>> signal is sent. If no signals are sent it prints out the same message >>> killall does. >>> >>> >> Unfortunately that patch works but has unintended operation that can be >> seen with the following. >> >> sleep 1000 & >> pkill sleep >> No matching processes belonging to you were found >> [1]+ Terminated: 15 sleep 1 >> >> It then kills sleep and still prints no processes belong to you message. >> >> Now pkill -v sleep on my system actually causes my Xserver to exit with a >> unexpected signal 15. >> >> Without the patches it works as it should... >> >> Overhead endured. >> >> >> > Ugh! ignore the pkill -v comment. Should have noticed the -V instead. > > > -- > > jhell > > ___ freebsd-hackers@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/freebsd-hackers To unsubscribe, send any mail to "freebsd-hackers-unsubscr...@freebsd.org"
Re: [RFC] [patch] pkill verbose option
On Wed, 3 Feb 2010 12:52, jhell@ wrote: On Wed, 3 Feb 2010 10:00, eitanadlerlist@ wrote: I added an option to pkill which lists what processes it kills and what signal is sent. If no signals are sent it prints out the same message killall does. Unfortunately that patch works but has unintended operation that can be seen with the following. sleep 1000 & pkill sleep No matching processes belonging to you were found [1]+ Terminated: 15 sleep 1 It then kills sleep and still prints no processes belong to you message. Now pkill -v sleep on my system actually causes my Xserver to exit with a unexpected signal 15. Without the patches it works as it should... Overhead endured. Ugh! ignore the pkill -v comment. Should have noticed the -V instead. -- jhell ___ freebsd-hackers@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/freebsd-hackers To unsubscribe, send any mail to "freebsd-hackers-unsubscr...@freebsd.org"
Re: [RFC] [patch] pkill verbose option
On Wed, 3 Feb 2010 10:00, eitanadlerlist@ wrote: I added an option to pkill which lists what processes it kills and what signal is sent. If no signals are sent it prints out the same message killall does. Unfortunately that patch works but has unintended operation that can be seen with the following. sleep 1000 & pkill sleep No matching processes belonging to you were found [1]+ Terminated: 15 sleep 1 It then kills sleep and still prints no processes belong to you message. Now pkill -v sleep on my system actually causes my Xserver to exit with a unexpected signal 15. Without the patches it works as it should... Overhead endured. -- jhell ___ freebsd-hackers@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/freebsd-hackers To unsubscribe, send any mail to "freebsd-hackers-unsubscr...@freebsd.org"