diff options
Diffstat (limited to 'src/firefox-io-slayer')
-rwxr-xr-x | src/firefox-io-slayer | 105 |
1 files changed, 0 insertions, 105 deletions
diff --git a/src/firefox-io-slayer b/src/firefox-io-slayer deleted file mode 100755 index 56ab849..0000000 --- a/src/firefox-io-slayer +++ /dev/null | |||
@@ -1,105 +0,0 @@ | |||
1 | #!/bin/bash | ||
2 | |||
3 | UNIT_NAME=ioslay | ||
4 | if [ "$1" = launch-unit ] | ||
5 | then | ||
6 | if systemctl --user is-active "$UNIT_NAME" | ||
7 | then systemctl --user restart "$UNIT_NAME" | ||
8 | else systemd-run --user -u "$UNIT_NAME" "$0" | ||
9 | fi | ||
10 | exit | ||
11 | fi | ||
12 | |||
13 | if [ -e /usr/lib/bash/sleep ] | ||
14 | then | ||
15 | enable -f /usr/lib/bash/sleep sleep | ||
16 | fi | ||
17 | |||
18 | export NOTICE=y | ||
19 | noticeLOG() { [ "$NOTICE" ] || return; echo "Notice: $*" >&2; } | ||
20 | debugLOG() { [ "$DBG" ] || return; echo "Debug: $*" >&2; } | ||
21 | |||
22 | . sliceweasel.lib.sh | ||
23 | |||
24 | vkill() | ||
25 | { | ||
26 | if [ $# = 0 ] | ||
27 | then | ||
28 | return | ||
29 | fi | ||
30 | ( | ||
31 | if [ "$(id -u)" = 0 ] | ||
32 | then sudo= | ||
33 | else sudo=sudo | ||
34 | fi | ||
35 | set -x | ||
36 | ps u "$@" | ||
37 | $sudo kill "$@" | ||
38 | ) | ||
39 | } | ||
40 | |||
41 | slay_slayer() | ||
42 | { | ||
43 | if [ "$ioslay" ] | ||
44 | then | ||
45 | children=$(for pid in $ioslay; do pgrep -P $ioslay; done) | ||
46 | grandchildren=$(for pid in $children; do pgrep -P $pid; done) | ||
47 | vkill $ioslay $children $grandchildren | ||
48 | fi | ||
49 | } | ||
50 | |||
51 | GROUP_BASENAME=firefox | ||
52 | |||
53 | group_procs=$(get_firefox_cgroup_procs) | ||
54 | |||
55 | ioslay= | ||
56 | lastprocs= | ||
57 | SIGNALLED= | ||
58 | trap 'SIGNALLED=y' SIGINT SIGTERM SIGHUP | ||
59 | while [ ! "$SIGNALLED" ] | ||
60 | do | ||
61 | if ! [ -e "$group_procs" ] | ||
62 | then | ||
63 | [ "$warned" ] || echo "Warning: firefox not running or cgroup not found" >&2 | ||
64 | warned=y | ||
65 | else | ||
66 | if [ "$warned" ] | ||
67 | then | ||
68 | echo "Found firefox cgroup: $group_procs" >&2 | ||
69 | warned= | ||
70 | fi | ||
71 | read -N 1000100 procs < "$group_procs" | ||
72 | if [ "$procs" ] | ||
73 | then | ||
74 | set -- | ||
75 | for pid in $procs | ||
76 | do | ||
77 | read comm < /proc/$pid/comm | ||
78 | case "$comm" in | ||
79 | 'Isolated Web Content' | 'Web Content' | 'Isolated Web Co') | ||
80 | set -- "$@" "$pid" | ||
81 | debugLOG "accept /proc/$pid/comm $comm" | ||
82 | ;; | ||
83 | *) | ||
84 | debugLOG "reject /proc/$pid/comm $comm" | ||
85 | esac | ||
86 | done | ||
87 | |||
88 | # echo "pids: ($*|$(echo $procs))" >&2 | ||
89 | if [ "$lastargs" != "$*" ] | ||
90 | then | ||
91 | slay_slayer | ||
92 | wait $ioslay | ||
93 | if [ $# -gt 0 ] | ||
94 | then | ||
95 | ioslay-firefox "$@" & | ||
96 | ioslay=$! | ||
97 | noticeLOG "Launched ioslay-firefox[$ioslay] $*" | ||
98 | fi | ||
99 | fi | ||
100 | lastargs=$* | ||
101 | fi | ||
102 | fi | ||
103 | sleep 1 | ||
104 | done | ||
105 | slay_slayer | ||