zsh-users
 help / color / mirror / code / Atom feed
* kill and pid files
@ 1997-06-18  7:25 Robert Stone
  1997-06-18 20:16 ` Timothy J Luoma
  0 siblings, 1 reply; 7+ messages in thread
From: Robert Stone @ 1997-06-18  7:25 UTC (permalink / raw)
  To: zsh-users


	I find myself using "kill -HUP $(cat /var/run/<program>.pid)"
constantly... in fact, as root I use that line much more often than using
a literal pid.
	Is there any reason kill should not take a filename as an
argument?  i.e. if the job specification is not a legal job name, or a
legal pid, why not try to open a file with that name and see if it's
first line is a valid pid?

	Here's the idea, but this thing is horribly slow at times.

function mykill {
    args=()
    if ! kill "$argv[@]" 2> /dev/null
    then while [ "$argv" ]
        do case "$argv[1]"
            in
              -s)
                args=("$args[@]" "$argv[1]" "$argv[2]")
                shift 2
                ;;
              -l)
                args=("$args[@]" "$@")
                shift "$#"
                ;;
              -*)
                args=("$args[@]" "$argv[1]")
                shift
                ;;
              *)
                if echo "$argv[1]" | egrep -q '^%[0-9]+$'
                then args=("$args[@]" "$argv[1]")
                    shift
                elif echo "$argv[1]" | egrep -q '^[0-9]+$'
                then args=("$args[@]" "$argv[1]")
                    shift
                elif [ -f "$argv[1]" ] &&
                    head -1 "$argv[1]" | egrep -q '^[0-9]+$'
                then args=("$args[@]" "$(head -1 "$argv[1]")")
                    shift
                else args=("$args[@]" "$argv[1]")
                    shift
                fi
                ;;
            esac
        done
        kill "$args[@]"
    fi
}



^ permalink raw reply	[flat|nested] 7+ messages in thread
* Re: kill and pid files
@ 1997-06-18 13:05 Wez Furlong
  0 siblings, 0 replies; 7+ messages in thread
From: Wez Furlong @ 1997-06-18 13:05 UTC (permalink / raw)
  To: Robert Stone, zsh-users

On Jun 18, 12:25am, Robert Stone wrote:

: 	I find myself using "kill -HUP $(cat /var/run/<program>.pid)"

Isn't it more preferable to use $(< /var/run/<program>.pid) ?
This would bypass running cat, and certainly speed up your function by
using zsh's internal file reading.

Feel free to correct me if I'm wrong :)



-- 
Wez - Electronics Undergraduate at the University of York
URL : http://www.twinklestar.demon.co.uk/

Insult Of The Day: Thou dissembling fool-born miscreant!


^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~1997-06-21 15:16 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
1997-06-18  7:25 kill and pid files Robert Stone
1997-06-18 20:16 ` Timothy J Luoma
1997-06-19  6:42   ` Zoltan Hidvegi
1997-06-19 12:19     ` Matt Welland
1997-06-21 15:07     ` Timothy J. Luoma
1997-06-19 10:53   ` Vardhan Varma
1997-06-18 13:05 Wez Furlong

Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/zsh/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).