blob: 556fe746a8b228099c2c183cb532f98eee5a314d (
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
|
#!/bin/bash
if [ -e /usr/lib/bash/sleep ]
then
enable -f /usr/lib/bash/sleep sleep
fi
. 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_BASENAME=firefox
uid=$(set -x; get_uid)
uid=1000
group=user.slice/user-$uid.slice/$GROUP_BASENAME
group_procs=/sys/fs/cgroup/$group/cgroup.procs
wantcomm='Web Content'
ioslay=
lastprocs=
SIGNALLED=
trap 'SIGNALLED=y' SIGINT SIGTERM SIGHUP
while [ ! "$SIGNALLED" ]
do
read -N 1000100 procs < "$group_procs"
if [ "$procs" ]
then
set --
for pid in $procs
do
read comm < /proc/$pid/comm
if [ "$comm" = "$wantcomm" ]
then
set -- "$@" "$pid"
fi
done
# echo "pids: ($*|$(echo $procs))" >&2
if [ "$lastargs" != "$*" ]
then
slay_slayer
wait $ioslay
ioslay-firefox "$@" &
ioslay=$!
fi
lastargs=$*
fi
sleep 1
done
slay_slayer
|