summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndrew Cady <d@cryptonomic.net>2022-04-08 21:34:40 -0400
committerAndrew Cady <d@cryptonomic.net>2022-04-08 21:34:40 -0400
commit4e81ea3c5d7cadfceca5610aa270313fdaa36c53 (patch)
treeb17ccf8e7f652bb227ac1b86b9f912c11a1fb27f
parent6a147c8e1bb1b6079446003a2b66582462230ccf (diff)
cleanup
-rwxr-xr-xfireslay79
-rwxr-xr-xioslay-firefox7
-rwxr-xr-xsliceweasel.lib.sh6
3 files changed, 19 insertions, 73 deletions
diff --git a/fireslay b/fireslay
index 892dbee..3c68ad5 100755
--- a/fireslay
+++ b/fireslay
@@ -2,69 +2,6 @@
2set -e 2set -e
3. sliceweasel.lib.sh 3. sliceweasel.lib.sh
4 4
5die()
6{
7 printf '%s: Error: %s\n' "$0" "$*" >&2
8 exit 1
9}
10
11parseopts()
12{
13 while [ $# -gt 0 ]
14 do
15 case "$1" in
16 -q | --quiet )
17 exec 2>/dev/null
18 ;;
19 -y | --kill-last-process )
20 FIRESLAY_KILL_LAST_PROCESS=y
21 ;;
22 --)
23 shift
24 break
25 ;;
26 -* )
27 die unknown option
28 ;;
29 *)
30 break
31 ;;
32 esac
33 shift
34 done
35 [ $# = 0 ] || die usage
36}
37
38main()
39{
40 parseopts "$@"
41
42 set -- $(web_content_pids)
43
44 (
45 case $# in
46 0 ) echo "$0: Warning: Not slaying: no Web Content process found." >&2
47 exit
48 ;;
49 1 ) if ! [ "$FIRESLAY_KILL_LAST_PROCESS" ]
50 then
51 echo "$0: Warning: Not slaying: only one 'Web Content' process. Specify -y to kill it." >&2
52 exit
53 fi
54 ;;
55 * ) shift
56 ;;
57 esac
58 set -x
59 ps $* >&2 &
60 kill $*
61 )
62
63 r=$?
64 ps $* >&2
65 exit $r
66}
67
68is_web_content() 5is_web_content()
69{ 6{
70 local comm state 7 local comm state
@@ -84,10 +21,18 @@ web_content_pids()
84} 21}
85 22
86FIREFOX_GROUP_PROCS=$(get_firefox_cgroup_procs) 23FIREFOX_GROUP_PROCS=$(get_firefox_cgroup_procs)
87if [ -e "$FIREFOX_GROUP_PROCS" ] 24
25[ -e "$FIREFOX_GROUP_PROCS" ] || die "Firefox group not found ($FIREFOX_GROUP_PROCS)"
26
27set -- $(web_content_pids)
28
29if [ $# = 0 ]
88then 30then
89 main "$@" 31 exit
90else
91 echo "Error: Firefox group not found ($FIREFOX_GROUP_PROCS)" >&2
92fi 32fi
93 33
34(
35 set -x
36 ps $* >&2
37 kill $*
38)
diff --git a/ioslay-firefox b/ioslay-firefox
index 5041260..40fbd7e 100755
--- a/ioslay-firefox
+++ b/ioslay-firefox
@@ -21,8 +21,6 @@ last()
21 printf '%s\n' "$*" 21 printf '%s\n' "$*"
22} 22}
23 23
24enable -f /usr/lib/bash/sleep sleep 2>/dev/null || true
25
26iotop_reader() 24iotop_reader()
27{ 25{
28 log= 26 log=
@@ -42,10 +40,7 @@ iotop_reader()
42 if [ "$(sum $log)" -gt 4 ] 40 if [ "$(sum $log)" -gt 4 ]
43 then 41 then
44 log= # this is year zero; all past history is erased. 42 log= # this is year zero; all past history is erased.
45 ( 43 fireslay
46 set -x
47 fireslay -y
48 )
49 fi 44 fi
50 else 45 else
51 log=$(last 10 $log 0) 46 log=$(last 10 $log 0)
diff --git a/sliceweasel.lib.sh b/sliceweasel.lib.sh
index d9a93c5..549e1e8 100755
--- a/sliceweasel.lib.sh
+++ b/sliceweasel.lib.sh
@@ -1,4 +1,10 @@
1#!/bin/sh 1#!/bin/sh
2die()
3{
4 printf '%s: Error: %s\n' "$0" "$*" >&2
5 exit 1
6}
7
2get_age() 8get_age()
3{ 9{
4 local mtime now 10 local mtime now