Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Re: kill and pid files



Timothy J. Luoma wrote:
> 	Zoltan Hidvegi <hzoli@xxxxxxxxxxxxxxxxxxx> wrote in
[...]
> > Oh, this is a really overcomplicated solution for a simple problem.  How
> > about this:
> >
> > pid () {
> > local i
> > for i
> > do
> > ps acx | sed -n "s/ *\([0-9]*\) .* $i *\$/\1/p"
> > done
> > }
> 
> Yes but what if there is more than one process by that name?
> 
> I usually want to kill them all.  This just kills one of them, whereas my
> solution kills them all (that's what the 'tr' part is for).... however, it
[...]
> it also takes multiple arguments, in case you need to kill several things at once

Did you try my script? kill -TERM `pid foo bar baz` will kill all foo, bar,
baz named processes.  And of course it can be improved, since sed is not
necessary:

pid () {
    setopt localoptions extendedglob
    local i
    for i
    do
        echo "${(M)${(M)${(f)$(ps acx)}:%* $i #}## #<->}"
    done
}

-- End of PGP signed section, PGP failed!

Where can I find your PGP key?  I tried finger -l, your web page and the
key servers with no luck.

Zoltan



Messages sorted by: Reverse Date, Date, Thread, Author