summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndrew Cady <d@cryptonomic.net>2021-10-19 08:01:55 -0400
committerAndrew Cady <d@cryptonomic.net>2021-10-19 08:03:24 -0400
commit47c72d59b2fe1234df8fad442f2ad26c2f84fab9 (patch)
tree145ea7b5fac7a046c013e8ccc76cd2ef0653f0dc
parent01144e666dd1b3daed500ab230fbc7d0266962da (diff)
simplify & improve fireslay
-rwxr-xr-xfireslay52
1 files changed, 28 insertions, 24 deletions
diff --git a/fireslay b/fireslay
index 1826561..fe5088a 100755
--- a/fireslay
+++ b/fireslay
@@ -1,8 +1,10 @@
1#!/bin/sh 1#!/bin/sh
2set -e 2
3d=$(mktemp -d) 3if [ "$1" = -q ]
4trap "cd /; rm -r '$d'" EXIT 4then
5cd "$d" 5 exec 2>/dev/null
6 shift
7fi
6 8
7web_content_pids() 9web_content_pids()
8{ 10{
@@ -15,24 +17,26 @@ web_content_pids()
15 } 17 }
16} 18}
17 19
18lesser_tabs() 20web_content_pids >&2
19{ 21set -- $(web_content_pids | tac)
20 web_content_pids > pids 22
21 if [ $(wc -l < pids) -gt 1 ] 23case $# in
22 then 24 0)
23 sed 1d < pids | tac 25 echo "$0: Warning: Not slaying: no Web Content process found." >&2
24 fi 26 exit
25} 27 ;;
28 1)
29 echo "$0: Warning: Not slaying: only one Web Content process found." >&2
30 ps $* >&2
31 exit
32 ;;
33esac
26 34
27FIRST=y 35(
28for tab in $(lesser_tabs) 36 set -x
29do 37 ps $1 >&2
30 if [ "$FIRST" ] 38 kill $1
31 then 39)
32 FIRST= 40r=$?
33 ps $tab 41ps $* >&2
34 (set -x 42exit $r
35 kill "$tab")
36 fi
37 ps $tab
38done