zsh-users
 help / color / mirror / code / Atom feed
From: Robert Stone <rstone@accesscom.com>
To: zsh-users@math.gatech.edu
Subject: kill and pid files
Date: Wed, 18 Jun 1997 00:25:30 -0700 (PDT)	[thread overview]
Message-ID: <Pine.LNX.3.96.970617232424.28210A-100000@dreamer> (raw)


	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
}



             reply	other threads:[~1997-06-18  7:35 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
1997-06-18  7:25 Robert Stone [this message]
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

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=Pine.LNX.3.96.970617232424.28210A-100000@dreamer \
    --to=rstone@accesscom.com \
    --cc=zsh-users@math.gatech.edu \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).