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
#!/bin/sh name=$1 pid=$2 kill $pid set -- . while kill -0 $pid 2>/dev/null do set -- "$@" "." if [ $# -gt 4 ] then kill kill -9 $pid 2> /dev/null break fi sleep 1 done set -- . while kill -0 $pid 2>/dev/null do set -- "$@" "." if [ $# -gt 4 ]; then exit 1; fi sleep 1 done exit 0