blob: 1926e191d9f5827fc5592b6c6df42f7670f0c765 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
|
#!/bin/sh
die()
{
printf '%s: Error: %s\n' "$0" "$*" >&2
exit 1
}
parseopts()
{
while [ $# -gt 0 ]
do
case "$1" in
-q | --quiet )
exec 2>/dev/null
;;
-y | --kill-last-process )
FIRESLAY_KILL_LAST_PROCESS=y
;;
--)
shift
break
;;
-* )
die unknown option
;;
*)
break
;;
esac
shift
done
[ $# = 0 ] || die usage
}
main()
{
parseopts "$@"
set -- $(web_content_pids)
(
case $# in
0 ) echo "$0: Warning: Not slaying: no Web Content process found." >&2
exit
;;
1 ) if ! [ "$FIRESLAY_KILL_LAST_PROCESS" ]
then
echo "$0: Warning: Not slaying: only one 'Web Content' process. Specify -y to kill it." >&2
exit
fi
;;
* ) shift
;;
esac
set -x
ps $* >&2
kill $*
)
r=$?
ps $* >&2
exit $r
}
web_content_pids()
{
top -w512 -bn1 -o '%MEM' | sed -e '1,/^$/d' | {
while read line
do set -- $line
[ "${12} ${13}" = "Web Content" ] || continue
[ "${8}" != Z ] || continue
echo $1
done
}
}
main "$@"
|