mirror of
git://xwords.git.sourceforge.net/gitroot/xwords/xwords
synced 2024-12-30 10:26:58 +01:00
option to randomly kill xwords instances
This commit is contained in:
parent
192fb50bf8
commit
7338a706cb
1 changed files with 23 additions and 0 deletions
|
@ -8,6 +8,7 @@ PORT=${PORT:-10999}
|
||||||
QUIT=${QUIT:-"-q 2"}
|
QUIT=${QUIT:-"-q 2"}
|
||||||
USE_CURSES=${USE_CURSES:="yes"}
|
USE_CURSES=${USE_CURSES:="yes"}
|
||||||
WAIT_MAX=${WAIT_MAX:-10}
|
WAIT_MAX=${WAIT_MAX:-10}
|
||||||
|
KILL_INTERVAL_SECS=${KILL_INTERVAL_SECS:-0}
|
||||||
|
|
||||||
RUN_NAME=$(basename $0)_$$
|
RUN_NAME=$(basename $0)_$$
|
||||||
|
|
||||||
|
@ -23,6 +24,9 @@ EOF
|
||||||
echo " env: HOST: remote host; default: localhost"
|
echo " env: HOST: remote host; default: localhost"
|
||||||
echo " env: PORT: remote port; default: 10999"
|
echo " env: PORT: remote port; default: 10999"
|
||||||
echo " env: WAIT_MAX: most seconds to wait between moves; default: 10"
|
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
|
exit 0
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -76,6 +80,23 @@ check_logs() {
|
||||||
fi
|
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() {
|
do_one() {
|
||||||
CROOT=${1:-$(exec sh -c 'echo $PPID')}
|
CROOT=${1:-$(exec sh -c 'echo $PPID')}
|
||||||
INDX=1
|
INDX=1
|
||||||
|
@ -171,4 +192,6 @@ for II in $(seq $NRUNS); do
|
||||||
do_one $II &
|
do_one $II &
|
||||||
done
|
done
|
||||||
|
|
||||||
|
kill_at_random &
|
||||||
|
|
||||||
wait
|
wait
|
||||||
|
|
Loading…
Reference in a new issue