summaryrefslogtreecommitdiff
path: root/fireslay
blob: 0b26c86ed09404bb7b01ac0789662bdbddfe26cc (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
#!/bin/sh

if [ "$1" = -q ]
then
    exec 2>/dev/null
    shift
fi

web_content_pids()
{
    top -w512 -bn1 -o '%MEM' | sed -e '1,/^$/d' | {
        while read line
        do set -- $line
           [ "${12} ${13}" = "Web Content" ] || continue
           [ "${8}" != Z ] || continue
           echo $1
        done
    }
}

set -- $(web_content_pids | tac)

case $# in
    0)
        echo "$0: Warning: Not slaying: no Web Content process found." >&2
        exit
        ;;
    1)
        echo "$0: Warning: Not slaying: only one Web Content process found." >&2
        ps $* >&2
        exit
        ;;
esac

(
    set -x
    ps $1 >&2
    kill $1
)
r=$?
ps $* >&2
exit $r