#!/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 echo $1 done } } web_content_pids >&2 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