summaryrefslogtreecommitdiff
path: root/ioslay-mgr.sh
diff options
context:
space:
mode:
Diffstat (limited to 'ioslay-mgr.sh')
-rwxr-xr-xioslay-mgr.sh67
1 files changed, 11 insertions, 56 deletions
diff --git a/ioslay-mgr.sh b/ioslay-mgr.sh
index 85ff4d7..423aa5e 100755
--- a/ioslay-mgr.sh
+++ b/ioslay-mgr.sh
@@ -1,58 +1,6 @@
1#!/bin/bash 1#!/bin/bash
2 2
3ioslay= 3. sliceweasel.lib.sh
4each_new_process()
5{
6 while read pid _
7 do
8 read -N 10001000 procs < /sys/fs/cgroup/$group/cgroup.procs
9 set -- $procs
10
11 for pid in "$@"
12 do
13 if read comm < /proc/$pid/comm && [ "$comm" = 'Web Content' ]
14 then
15 set -- "$@" "$1"
16 fi
17 shift
18 done
19
20 if [ "$ioslay" ]
21 then
22 children=$(pgrep -P $ioslay)
23 if [ "$children" ]
24 then
25 kill $children
26 fi
27 wait $ioslay
28 fi
29
30 if [ $# -gt 0 ]
31 then
32 ioslay-firefox "$@" &
33 ioslay=$!
34 fi
35 done
36}
37
38get_uid()
39{
40 (
41 if [ "$SUDO_USER" ]
42 then
43 IFS=:
44 set -- $(getent passwd "${SUDO_USER}") || return
45 echo $3
46 else
47 id -un
48 fi
49 )
50}
51
52#cgroup-show-each-new-process "$group" | grep --line-buffered 'Web Content' | each_new_process
53
54# Really, could just check for any/first cgroup with processes and basename
55# 'firefox'. Fork for each one.
56 4
57vkill() 5vkill()
58{ 6{
@@ -61,9 +9,13 @@ vkill()
61 return 9 return
62 fi 10 fi
63 ( 11 (
12 if [ "$(id -u)" = 0 ]
13 then sudo=
14 else sudo=sudo
15 fi
64 set -x 16 set -x
65 ps u "$@" 17 ps u "$@"
66 sudo kill "$@" 18 $sudo kill "$@"
67 ) 19 )
68} 20}
69 21
@@ -77,8 +29,11 @@ slay_slayer()
77 fi 29 fi
78} 30}
79 31
32GROUP_BASENAME=firefox
33
34uid=$(set -x; get_uid)
80uid=1000 35uid=1000
81group=user.slice/user-$uid.slice/firefox 36group=user.slice/user-$uid.slice/$GROUP_BASENAME
82group_procs=/sys/fs/cgroup/$group/cgroup.procs 37group_procs=/sys/fs/cgroup/$group/cgroup.procs
83wantcomm='Web Content' 38wantcomm='Web Content'
84ioslay= 39ioslay=
@@ -105,7 +60,7 @@ do
105 then 60 then
106 slay_slayer 61 slay_slayer
107 wait $ioslay 62 wait $ioslay
108 sudo ioslay-firefox "$@" & 63 ioslay-firefox "$@" &
109 ioslay=$! 64 ioslay=$!
110 fi 65 fi
111 lastargs=$* 66 lastargs=$*