option to randomly kill xwords instances

This commit is contained in:
ehouse 2009-07-29 04:31:23 +00:00
parent 192fb50bf8
commit 7338a706cb

View file

@ -8,6 +8,7 @@ PORT=${PORT:-10999}
QUIT=${QUIT:-"-q 2"}
USE_CURSES=${USE_CURSES:="yes"}
WAIT_MAX=${WAIT_MAX:-10}
KILL_INTERVAL_SECS=${KILL_INTERVAL_SECS:-0}
RUN_NAME=$(basename $0)_$$
@ -23,6 +24,9 @@ EOF
echo " env: HOST: remote host; default: localhost"
echo " env: PORT: remote port; default: 10999"
echo " env: WAIT_MAX: most seconds to wait between moves; default: 10"
echo " env: KILL_INTERVAL_SECS: kill a random xwords every "
echo " this many seconds; 0 to disable; cur: $KILL_INTERVAL_SECS"
exit 0
}
@ -76,6 +80,23 @@ check_logs() {
fi
}
kill_at_random() {
if [ -n "$KILL_INTERVAL_SECS" ]; then
if [ $KILL_INTERVAL_SECS -gt 0 ]; then
while [ -d /tmp/$RUN_NAME ]; do
sleep $KILL_INTERVAL_SECS
set $(pidof xwords)
shift $(($#/2))
PID=$1
if [ -n "$PID" ]; then
echo "killing pid $PID"
kill -INT $PID
fi
done
fi
fi
}
do_one() {
CROOT=${1:-$(exec sh -c 'echo $PPID')}
INDX=1
@ -171,4 +192,6 @@ for II in $(seq $NRUNS); do
do_one $II &
done
kill_at_random &
wait