diff options
author | Andrew Cady <d@cryptonomic.net> | 2021-10-19 08:01:55 -0400 |
---|---|---|
committer | Andrew Cady <d@cryptonomic.net> | 2021-10-19 08:03:24 -0400 |
commit | 47c72d59b2fe1234df8fad442f2ad26c2f84fab9 (patch) | |
tree | 145ea7b5fac7a046c013e8ccc76cd2ef0653f0dc | |
parent | 01144e666dd1b3daed500ab230fbc7d0266962da (diff) |
simplify & improve fireslay
-rwxr-xr-x | fireslay | 52 |
1 files changed, 28 insertions, 24 deletions
@@ -1,8 +1,10 @@ | |||
1 | #!/bin/sh | 1 | #!/bin/sh |
2 | set -e | 2 | |
3 | d=$(mktemp -d) | 3 | if [ "$1" = -q ] |
4 | trap "cd /; rm -r '$d'" EXIT | 4 | then |
5 | cd "$d" | 5 | exec 2>/dev/null |
6 | shift | ||
7 | fi | ||
6 | 8 | ||
7 | web_content_pids() | 9 | web_content_pids() |
8 | { | 10 | { |
@@ -15,24 +17,26 @@ web_content_pids() | |||
15 | } | 17 | } |
16 | } | 18 | } |
17 | 19 | ||
18 | lesser_tabs() | 20 | web_content_pids >&2 |
19 | { | 21 | set -- $(web_content_pids | tac) |
20 | web_content_pids > pids | 22 | |
21 | if [ $(wc -l < pids) -gt 1 ] | 23 | case $# 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 | ;; | ||
33 | esac | ||
26 | 34 | ||
27 | FIRST=y | 35 | ( |
28 | for tab in $(lesser_tabs) | 36 | set -x |
29 | do | 37 | ps $1 >&2 |
30 | if [ "$FIRST" ] | 38 | kill $1 |
31 | then | 39 | ) |
32 | FIRST= | 40 | r=$? |
33 | ps $tab | 41 | ps $* >&2 |
34 | (set -x | 42 | exit $r |
35 | kill "$tab") | ||
36 | fi | ||
37 | ps $tab | ||
38 | done | ||