blob: 892dbee338ee998a999abf4466767095e1b55622 (
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
80
81
82
83
84
85
86
87
88
89
90
91
92
93
|
#!/bin/sh
set -e
. sliceweasel.lib.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
}
is_web_content()
{
local comm state
read comm < /proc/"$1"/comm && [ "$comm" = 'Web Content' ] &&
read _ _ state _ < /proc/"$1"/stat && [ "$state" != Z ] || return
}
web_content_pids()
{
while read pid
do
if is_web_content $pid
then
echo $pid
fi
done < $FIREFOX_GROUP_PROCS
}
FIREFOX_GROUP_PROCS=$(get_firefox_cgroup_procs)
if [ -e "$FIREFOX_GROUP_PROCS" ]
then
main "$@"
else
echo "Error: Firefox group not found ($FIREFOX_GROUP_PROCS)" >&2
fi
|