#!/bin/bash DISPLAY=$1 if [ -e /usr/lib/bash/sleep ] then enable -f /usr/lib/bash/sleep sleep fi export NOTICE=y noticeLOG() { [ "$NOTICE" ] || return; echo "Notice: $*" >&2; } debugLOG() { [ "$DBG" ] || return; echo "Debug: $*" >&2; } . sliceweasel.lib.sh vkill() { if [ $# = 0 ] then return fi ( if [ "$(id -u)" = 0 ] then sudo= else sudo=sudo fi set -x ps u "$@" $sudo kill "$@" ) } slay_slayer() { if [ "$ioslay" ] then children=$(for pid in $ioslay; do pgrep -P $ioslay; done) grandchildren=$(for pid in $children; do pgrep -P $pid; done) vkill $ioslay $children $grandchildren fi } group_procs=$(get_firefox_cgroup_procs) ioslay= lastprocs= SIGNALLED= trap 'SIGNALLED=y' SIGINT SIGTERM SIGHUP while [ ! "$SIGNALLED" ] do if ! [ -e "$group_procs" ] then [ "$warned" ] || echo "Warning: firefox not running or cgroup not found" >&2 warned=y else if [ "$warned" ] then echo "Found firefox cgroup: $group_procs" >&2 warned= fi read -N 1000100 procs < "$group_procs" if [ "$procs" ] then set -- for pid in $procs do read comm < /proc/$pid/comm case "$comm" in 'Isolated Web Content' | 'Web Content' | 'Isolated Web Co') set -- "$@" "$pid" debugLOG "accept /proc/$pid/comm $comm" ;; *) debugLOG "reject /proc/$pid/comm $comm" esac done # echo "pids: ($*|$(echo $procs))" >&2 if [ "$lastargs" != "$*" ] then slay_slayer wait $ioslay if [ $# -gt 0 ] then ioslay-firefox "$@" & ioslay=$! noticeLOG "Launched ioslay-firefox[$ioslay] $*" fi fi lastargs=$* fi fi sleep 1 done slay_slayer