summaryrefslogtreecommitdiff
path: root/fireslay
diff options
context:
space:
mode:
Diffstat (limited to 'fireslay')
-rwxr-xr-xfireslay89
1 files changed, 63 insertions, 26 deletions
diff --git a/fireslay b/fireslay
index 0b26c86..1926e19 100755
--- a/fireslay
+++ b/fireslay
@@ -1,10 +1,67 @@
1#!/bin/sh 1#!/bin/sh
2 2
3if [ "$1" = -q ] 3die()
4then 4{
5 exec 2>/dev/null 5 printf '%s: Error: %s\n' "$0" "$*" >&2
6 shift 6 exit 1
7fi 7}
8
9parseopts()
10{
11 while [ $# -gt 0 ]
12 do
13 case "$1" in
14 -q | --quiet )
15 exec 2>/dev/null
16 ;;
17 -y | --kill-last-process )
18 FIRESLAY_KILL_LAST_PROCESS=y
19 ;;
20 --)
21 shift
22 break
23 ;;
24 -* )
25 die unknown option
26 ;;
27 *)
28 break
29 ;;
30 esac
31 shift
32 done
33 [ $# = 0 ] || die usage
34}
35
36main()
37{
38 parseopts "$@"
39
40 set -- $(web_content_pids)
41
42 (
43 case $# in
44 0 ) echo "$0: Warning: Not slaying: no Web Content process found." >&2
45 exit
46 ;;
47 1 ) if ! [ "$FIRESLAY_KILL_LAST_PROCESS" ]
48 then
49 echo "$0: Warning: Not slaying: only one 'Web Content' process. Specify -y to kill it." >&2
50 exit
51 fi
52 ;;
53 * ) shift
54 ;;
55 esac
56 set -x
57 ps $* >&2
58 kill $*
59 )
60
61 r=$?
62 ps $* >&2
63 exit $r
64}
8 65
9web_content_pids() 66web_content_pids()
10{ 67{
@@ -18,25 +75,5 @@ web_content_pids()
18 } 75 }
19} 76}
20 77
21set -- $(web_content_pids | tac) 78main "$@"
22 79
23case $# in
24 0)
25 echo "$0: Warning: Not slaying: no Web Content process found." >&2
26 exit
27 ;;
28 1)
29 echo "$0: Warning: Not slaying: only one Web Content process found." >&2
30 ps $* >&2
31 exit
32 ;;
33esac
34
35(
36 set -x
37 ps $1 >&2
38 kill $1
39)
40r=$?
41ps $* >&2
42exit $r