diff options
author | Debian Live user <user@debian-BULLSEYE-live-builder-AMD64> | 2023-04-28 21:47:08 -0400 |
---|---|---|
committer | Debian Live user <user@debian-BULLSEYE-live-builder-AMD64> | 2023-04-28 21:47:08 -0400 |
commit | b00a5efe39bf1195ef0c8037093df2604afa911d (patch) | |
tree | f1869639f3cc74f6e9eb7d7efc275eaec78b7a53 /src/firefox-io-slayer-redux | |
parent | 421d0b23592c1e5838c057813b5615581494c225 (diff) |
Got some new firefox launch code working.
Now it uses a template file parameterized on $DISPLAY.
Unfortunately, this file needs to be generated dynamically on install
in order to set the IO parameters. (Might use systemd edit system for
this, actually.)
The ioslayer is also parameterized and started by the firefox unit file.
Needs a little cleanup / removal of old code.
Diffstat (limited to 'src/firefox-io-slayer-redux')
-rwxr-xr-x | src/firefox-io-slayer-redux | 95 |
1 files changed, 95 insertions, 0 deletions
diff --git a/src/firefox-io-slayer-redux b/src/firefox-io-slayer-redux new file mode 100755 index 0000000..fe54e37 --- /dev/null +++ b/src/firefox-io-slayer-redux | |||
@@ -0,0 +1,95 @@ | |||
1 | #!/bin/bash | ||
2 | |||
3 | DISPLAY=$1 | ||
4 | |||
5 | if [ -e /usr/lib/bash/sleep ] | ||
6 | then | ||
7 | enable -f /usr/lib/bash/sleep sleep | ||
8 | fi | ||
9 | |||
10 | export NOTICE=y | ||
11 | noticeLOG() { [ "$NOTICE" ] || return; echo "Notice: $*" >&2; } | ||
12 | debugLOG() { [ "$DBG" ] || return; echo "Debug: $*" >&2; } | ||
13 | |||
14 | . sliceweasel.lib.sh | ||
15 | |||
16 | vkill() | ||
17 | { | ||
18 | if [ $# = 0 ] | ||
19 | then | ||
20 | return | ||
21 | fi | ||
22 | ( | ||
23 | if [ "$(id -u)" = 0 ] | ||
24 | then sudo= | ||
25 | else sudo=sudo | ||
26 | fi | ||
27 | set -x | ||
28 | ps u "$@" | ||
29 | $sudo kill "$@" | ||
30 | ) | ||
31 | } | ||
32 | |||
33 | slay_slayer() | ||
34 | { | ||
35 | if [ "$ioslay" ] | ||
36 | then | ||
37 | children=$(for pid in $ioslay; do pgrep -P $ioslay; done) | ||
38 | grandchildren=$(for pid in $children; do pgrep -P $pid; done) | ||
39 | vkill $ioslay $children $grandchildren | ||
40 | fi | ||
41 | } | ||
42 | |||
43 | group_procs=$(get_firefox_cgroup_procs) | ||
44 | |||
45 | ioslay= | ||
46 | lastprocs= | ||
47 | SIGNALLED= | ||
48 | trap 'SIGNALLED=y' SIGINT SIGTERM SIGHUP | ||
49 | while [ ! "$SIGNALLED" ] | ||
50 | do | ||
51 | if ! [ -e "$group_procs" ] | ||
52 | then | ||
53 | [ "$warned" ] || echo "Warning: firefox not running or cgroup not found" >&2 | ||
54 | warned=y | ||
55 | else | ||
56 | if [ "$warned" ] | ||
57 | then | ||
58 | echo "Found firefox cgroup: $group_procs" >&2 | ||
59 | warned= | ||
60 | fi | ||
61 | read -N 1000100 procs < "$group_procs" | ||
62 | if [ "$procs" ] | ||
63 | then | ||
64 | set -- | ||
65 | for pid in $procs | ||
66 | do | ||
67 | read comm < /proc/$pid/comm | ||
68 | case "$comm" in | ||
69 | 'Isolated Web Content' | 'Web Content' | 'Isolated Web Co') | ||
70 | set -- "$@" "$pid" | ||
71 | debugLOG "accept /proc/$pid/comm $comm" | ||
72 | ;; | ||
73 | *) | ||
74 | debugLOG "reject /proc/$pid/comm $comm" | ||
75 | esac | ||
76 | done | ||
77 | |||
78 | # echo "pids: ($*|$(echo $procs))" >&2 | ||
79 | if [ "$lastargs" != "$*" ] | ||
80 | then | ||
81 | slay_slayer | ||
82 | wait $ioslay | ||
83 | if [ $# -gt 0 ] | ||
84 | then | ||
85 | ioslay-firefox "$@" & | ||
86 | ioslay=$! | ||
87 | noticeLOG "Launched ioslay-firefox[$ioslay] $*" | ||
88 | fi | ||
89 | fi | ||
90 | lastargs=$* | ||
91 | fi | ||
92 | fi | ||
93 | sleep 1 | ||
94 | done | ||
95 | slay_slayer | ||