Re: Small pgrep/pkill enhancement
On Sun, 12 Jun 2011 16:31:32 + Kevin Chadwick wrote: > On Sun, 12 Jun 2011 00:15:58 +0200 > Benny Lofgren wrote: > > > Me personally, I'm scared as hell using pkill at all. I've never been > > concerned with not killing *enough*, it's almost always that I'm afraid > > I'm killing too *much*... > > Most of the time, the regex matching makes it usable. I'd rather see > that expanded than case sensitivity. > Of course you can use ps -auxww | egrep | cut etc. etc. when needed, instead of pgrep but that sort of defies the point of pgrep.
Re: Small pgrep/pkill enhancement
On Sun, 12 Jun 2011 10:41:16 -0500 Chris Bennett wrote: > I would like a verbose option where I can be notified if nothing matched. /usr/bin/pgrep asxbabsjkcnjklcneo || /bin/echo "Nout matched"
Re: Small pgrep/pkill enhancement
On Sun, Jun 12, 2011 at 04:31:32PM +, Kevin Chadwick wrote: > On Sun, 12 Jun 2011 00:15:58 +0200 > Benny Lofgren wrote: > > > Me personally, I'm scared as hell using pkill at all. I've never been > > concerned with not killing *enough*, it's almost always that I'm afraid > > I'm killing too *much*... > > Most of the time, the regex matching makes it usable. I'd rather see > that expanded than case sensitivity. > I would like a verbose option where I can be notified if nothing matched. I far prefer to use pkill over kill. For example, killing off many gnashes! But I always want success when I use it. I dislike having to verify afterward manually my 2 cents.
Re: Small pgrep/pkill enhancement
On Sun, 12 Jun 2011 00:15:58 +0200 Benny Lofgren wrote: > Me personally, I'm scared as hell using pkill at all. I've never been > concerned with not killing *enough*, it's almost always that I'm afraid > I'm killing too *much*... Most of the time, the regex matching makes it usable. I'd rather see that expanded than case sensitivity.
Re: Small pgrep/pkill enhancement
2011/6/12 Philip Guenther > On Sat, Jun 11, 2011 at 7:19 PM, Ted Unangst > wrote: > > Funny enough, when pkill was first added I added an option to confirm > > each kill. Guess what letter it used? That's right, -i, modeled > > after rm. > > "Confirm each kill"? Ah, that's the option to follow up each kill > with a SIGKILL between the fds, right? > > More like "sending in a team and streaming it live to the president"-style "confirm each kill". =) -- To our sweethearts and wives. May they never meet. -- 19th century toast
Re: Small pgrep/pkill enhancement
On Sat, Jun 11, 2011 at 07:33:51PM -0700, Philip Guenther wrote: > On Sat, Jun 11, 2011 at 7:19 PM, Ted Unangst wrote: > > Funny enough, when pkill was first added I added an option to confirm > > each kill. Guess what letter it used? That's right, -i, modeled > > after rm. > > "Confirm each kill"? Ah, that's the option to follow up each kill > with a SIGKILL between the fds, right? > > > Philip Guenther Here with the process police, we like to kill by number. -Otto PS: if you don't get the reference you could listen to the guest performance of Sting performing "Murder by Numbers" with Frank Zappa's band on the "Broadway the Hard Way" album. http://www.youtube.com/watch?v=ToReX88lzkk That'll end this sunday's diversion.
Re: Small pgrep/pkill enhancement
On Sat, Jun 11, 2011 at 7:19 PM, Ted Unangst wrote: > Funny enough, when pkill was first added I added an option to confirm > each kill. Guess what letter it used? That's right, -i, modeled > after rm. "Confirm each kill"? Ah, that's the option to follow up each kill with a SIGKILL between the fds, right? Philip Guenther
Re: Small pgrep/pkill enhancement
On Sat, Jun 11, 2011 at 6:15 PM, Benny Lofgren wrote: >> Hmmm. Two of (arguably) the four best known BSD distributions have it. >> The idea of -i meaning case insensitivity is there already in other (1) >> commands, so I'd say it makes sense to add. >> >> From a practical standpoint, I'm all for it. I've missed killing things >> because of this. > > Me personally, I'm scared as hell using pkill at all. I've never been > concerned with not killing *enough*, it's almost always that I'm afraid > I'm killing too *much*... Funny enough, when pkill was first added I added an option to confirm each kill. Guess what letter it used? That's right, -i, modeled after rm.
Re: Small pgrep/pkill enhancement
Wrong thread :( On 11 June 2011 19:24, Christiano F. Haesbaert wrote: > The cleaner sometimes accidentaly pushes the power button of one of my > machines. > > So +1.
Re: Small pgrep/pkill enhancement
The cleaner sometimes accidentaly pushes the power button of one of my machines. So +1.
Re: Small pgrep/pkill enhancement
On 2011-06-11 23.07, STeve Andre' wrote: >> NetBSD has that since March 2005 (committed by sketch@). >> FreeBSD copied it from NetBSD a few days later. >> procps.cvs.sourceforge.net (used e.g. in Debian) does not have -i. >> OpenSolaris does not have -i. >> >> So I'd say we shouldn't add it. >> >> It is not terribly useful; hopefully, you at least know >> how the processes you are searching for are called. >> Even if not, you can use ps ax | grep -i to find out, >> then use the exact name you found for pkill. >> Personally, i never felt a need for pkill -i, >> although i'm using pkill a lot. >> It is not universal, so it is likely to degrade interoperability. >> > Hmmm. Two of (arguably) the four best known BSD distributions have it. > The idea of -i meaning case insensitivity is there already in other (1) > commands, so I'd say it makes sense to add. > > From a practical standpoint, I'm all for it. I've missed killing things > because of this. Me personally, I'm scared as hell using pkill at all. I've never been concerned with not killing *enough*, it's almost always that I'm afraid I'm killing too *much*... That said, there is merit in adding -i since it is quite consistently used in many places, so I say go for it unless it collides with a switch in some other major *nix (of which I can't think of any right now). But it's really not a biggie in my opinion and I fully recognize Ingo's standpoint as valid as well although I have a hard time seeing it being seriously used in portable scripts, which would make the interoperability argument a bit moot. If I look at myself I'd probably never use it in pkill but perhaps occasionally in pgrep. Regards, /Benny -- internetlabbet.se / work: +46 8 551 124 80 / "Words must Benny Lvfgren/ mobile: +46 70 718 11 90 / be weighed, / fax:+46 8 551 124 89/not counted." /email: benny -at- internetlabbet.se
Re: Small pgrep/pkill enhancement
On 06/11/11 16:44, Ingo Schwarze wrote: Hi, Jonathan Perkin wrote on Tue, May 17, 2011 at 11:02:05PM +0100: Add -i to ignore case when matching process name It seems nobody picked this up, so i had a look at it. NetBSD has that since March 2005 (committed by sketch@). FreeBSD copied it from NetBSD a few days later. procps.cvs.sourceforge.net (used e.g. in Debian) does not have -i. OpenSolaris does not have -i. So I'd say we shouldn't add it. It is not terribly useful; hopefully, you at least know how the processes you are searching for are called. Even if not, you can use ps ax | grep -i to find out, then use the exact name you found for pkill. Personally, i never felt a need for pkill -i, although i'm using pkill a lot. It is not universal, so it is likely to degrade interoperability. Yours, Ingo Hmmm. Two of (arguably) the four best known BSD distributions have it. The idea of -i meaning case insensitivity is there already in other (1) commands, so I'd say it makes sense to add. From a practical standpoint, I'm all for it. I've missed killing things because of this. --STeve Andre'
Re: Small pgrep/pkill enhancement
* On 2011-06-11 at 21:44 BST, Ingo Schwarze wrote: > Jonathan Perkin wrote on Tue, May 17, 2011 at 11:02:05PM +0100: > > > Add -i to ignore case when matching process name > > It seems nobody picked this up, so i had a look at it. > > NetBSD has that since March 2005 (committed by sketch@). Right, that's me, I figured it might be useful for OpenBSD too (which I started using recently). > FreeBSD copied it from NetBSD a few days later. > procps.cvs.sourceforge.net (used e.g. in Debian) does not have -i. > OpenSolaris does not have -i. > > So I'd say we shouldn't add it. > > It is not terribly useful; hopefully, you at least know > how the processes you are searching for are called. I don't remember the exact use case I required when I first added it, but I think it was for a group of similar-named processes where some where uppercase (but had the same name). > Even if not, you can use ps ax | grep -i to find out, > then use the exact name you found for pkill. > Personally, i never felt a need for pkill -i, > although i'm using pkill a lot. Well the primary use would be for pgrep (which is where I mainly use it), to avoid having to do what you typed above, but no problem if you don't feel it's worth having in OpenBSD. Cheers, -- Jonathan Perkin www.perkin.org.uk github.com/jperkin twitter.com/jperkin
Re: Small pgrep/pkill enhancement
Hi, Jonathan Perkin wrote on Tue, May 17, 2011 at 11:02:05PM +0100: > Add -i to ignore case when matching process name It seems nobody picked this up, so i had a look at it. NetBSD has that since March 2005 (committed by sketch@). FreeBSD copied it from NetBSD a few days later. procps.cvs.sourceforge.net (used e.g. in Debian) does not have -i. OpenSolaris does not have -i. So I'd say we shouldn't add it. It is not terribly useful; hopefully, you at least know how the processes you are searching for are called. Even if not, you can use ps ax | grep -i to find out, then use the exact name you found for pkill. Personally, i never felt a need for pkill -i, although i'm using pkill a lot. It is not universal, so it is likely to degrade interoperability. Yours, Ingo > Index: pkill.1 > === > RCS file: /cvs/src/usr.bin/pkill/pkill.1,v > retrieving revision 1.16 > diff -u -r1.16 pkill.1 > --- pkill.1 29 Sep 2010 07:44:56 - 1.16 > +++ pkill.1 17 May 2011 21:50:36 - > @@ -36,7 +36,7 @@ > .Nd find or signal processes by name > .Sh SYNOPSIS > .Nm pgrep > -.Op Fl flnovx > +.Op Fl filnovx > .Op Fl d Ar delim > .Op Fl G Ar gid > .Op Fl g Ar pgrp > @@ -48,7 +48,7 @@ > .Op Ar pattern ... > .Nm pkill > .Op Fl Ar signal > -.Op Fl fnovx > +.Op Fl finovx > .Op Fl G Ar gid > .Op Fl g Ar pgrp > .Op Fl P Ar ppid > @@ -93,6 +93,8 @@ > or > .Nm pkill > command. > +.It Fl i > +Ignore case when matching process name. > .It Fl l > Long output. > Print the process name in addition to the process ID for each matching > Index: pkill.c > === > RCS file: /cvs/src/usr.bin/pkill/pkill.c,v > retrieving revision 1.19 > diff -u -r1.19 pkill.c > --- pkill.c 10 Apr 2011 03:20:59 - 1.19 > +++ pkill.c 17 May 2011 21:50:36 - > @@ -85,6 +85,7 @@ > int longfmt; > int matchargs; > int fullmatch; > +int regflags = REG_EXTENDED; > kvm_t*kd; > pid_tmypid; > > @@ -149,7 +150,7 @@ > > criteria = 0; > > - while ((ch = getopt(argc, argv, "G:P:U:d:fg:lnos:t:u:vx")) != -1) > + while ((ch = getopt(argc, argv, "G:P:U:d:fg:ilnos:t:u:vx")) != -1) > switch (ch) { > case 'G': > makelist(&rgidlist, LT_GROUP, optarg); > @@ -175,6 +176,9 @@ > makelist(&pgrplist, LT_PGRP, optarg); > criteria = 1; > break; > + case 'i': > + regflags |= REG_ICASE; > + break; > case 'l': > if (!pgrep) > usage(); > @@ -243,7 +247,7 @@ >* Refine the selection. >*/ > for (; *argv != NULL; argv++) { > - if ((rv = regcomp(®, *argv, REG_EXTENDED)) != 0) { > + if ((rv = regcomp(®, *argv, regflags)) != 0) { > regerror(rv, ®, buf, sizeof(buf)); > errx(STATUS_BADUSAGE, "bad expression: %s", buf); > } > @@ -419,9 +423,9 @@ > const char *ustr; > > if (pgrep) > - ustr = "[-flnovx] [-d delim]"; > + ustr = "[-filnovx] [-d delim]"; > else > - ustr = "[-signal] [-fnovx]"; > + ustr = "[-signal] [-finovx]"; > > fprintf(stderr, "usage: %s %s [-G gid] [-g pgrp] [-P ppid] [-s sid] " > "[-t tty]\n\t[-U uid] [-u euid] [pattern ...]\n", __progname, ustr);
Small pgrep/pkill enhancement
Add -i to ignore case when matching process name Index: pkill.1 === RCS file: /cvs/src/usr.bin/pkill/pkill.1,v retrieving revision 1.16 diff -u -r1.16 pkill.1 --- pkill.1 29 Sep 2010 07:44:56 - 1.16 +++ pkill.1 17 May 2011 21:50:36 - @@ -36,7 +36,7 @@ .Nd find or signal processes by name .Sh SYNOPSIS .Nm pgrep -.Op Fl flnovx +.Op Fl filnovx .Op Fl d Ar delim .Op Fl G Ar gid .Op Fl g Ar pgrp @@ -48,7 +48,7 @@ .Op Ar pattern ... .Nm pkill .Op Fl Ar signal -.Op Fl fnovx +.Op Fl finovx .Op Fl G Ar gid .Op Fl g Ar pgrp .Op Fl P Ar ppid @@ -93,6 +93,8 @@ or .Nm pkill command. +.It Fl i +Ignore case when matching process name. .It Fl l Long output. Print the process name in addition to the process ID for each matching Index: pkill.c === RCS file: /cvs/src/usr.bin/pkill/pkill.c,v retrieving revision 1.19 diff -u -r1.19 pkill.c --- pkill.c 10 Apr 2011 03:20:59 - 1.19 +++ pkill.c 17 May 2011 21:50:36 - @@ -85,6 +85,7 @@ intlongfmt; intmatchargs; intfullmatch; +intregflags = REG_EXTENDED; kvm_t *kd; pid_t mypid; @@ -149,7 +150,7 @@ criteria = 0; - while ((ch = getopt(argc, argv, "G:P:U:d:fg:lnos:t:u:vx")) != -1) + while ((ch = getopt(argc, argv, "G:P:U:d:fg:ilnos:t:u:vx")) != -1) switch (ch) { case 'G': makelist(&rgidlist, LT_GROUP, optarg); @@ -175,6 +176,9 @@ makelist(&pgrplist, LT_PGRP, optarg); criteria = 1; break; + case 'i': + regflags |= REG_ICASE; + break; case 'l': if (!pgrep) usage(); @@ -243,7 +247,7 @@ * Refine the selection. */ for (; *argv != NULL; argv++) { - if ((rv = regcomp(®, *argv, REG_EXTENDED)) != 0) { + if ((rv = regcomp(®, *argv, regflags)) != 0) { regerror(rv, ®, buf, sizeof(buf)); errx(STATUS_BADUSAGE, "bad expression: %s", buf); } @@ -419,9 +423,9 @@ const char *ustr; if (pgrep) - ustr = "[-flnovx] [-d delim]"; + ustr = "[-filnovx] [-d delim]"; else - ustr = "[-signal] [-fnovx]"; + ustr = "[-signal] [-finovx]"; fprintf(stderr, "usage: %s %s [-G gid] [-g pgrp] [-P ppid] [-s sid] " "[-t tty]\n\t[-U uid] [-u euid] [pattern ...]\n", __progname, ustr);