commit 93ed9cc97060a6e70af0478984c2aa5d7b51c7b3 Author: Isis Lovecruft isis@torproject.org Date: Tue Oct 15 14:22:49 2013 +0000
Add script for killing the the server after N seconds; avoid running forever in CI. --- scripts/executioner | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+)
diff --git a/scripts/executioner b/scripts/executioner new file mode 100755 index 0000000..085b74d --- /dev/null +++ b/scripts/executioner @@ -0,0 +1,35 @@ +#!/bin/bash +############################################################################## +# +# executioner +# ----------- +# Run $@ for $1 seconds and then kill the process. +# +# :authors: Isis Agora Lovecruft, 0x2cdb8b35 +# :date: 21 April 2013 +# :version: 0.0.1 +############################################################################## + +set -vx -- + +function killitwithfire () { + trap - ALRM + kill -ALRM $prog 2>/dev/null + kill -9 $! 2>/dev/null && exit 0 +} + +function waitforit () { + trap "killitwithfire" ALRM + sleep $1& wait + kill -ALRM $$ +} + +waitforit $1& prog=$! ; shift ; +trap "killitwithfire" ALRM INT +"$@"& wait $! +RET=$? +if [[ "$(ps -ef | awk -v pid=$prog '$2==pid{print}{}')" != "" ]]; then + kill -ALRM $prog + wait $prog +fi +exit $RET
tor-commits@lists.torproject.org