Skip to content

Commit

Permalink
Better signal handling for multisim.sh (#4149)
Browse files Browse the repository at this point in the history
  • Loading branch information
alessio committed Apr 18, 2019
1 parent fc1c58a commit 9036430
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion cmd/gaia/contrib/sim/multisim.sh
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
#!/bin/bash

set -e

go mod download

seeds=(1 2 4 7 9 20 32 123 124 582 1893 2989 3012 4728 37827 981928 87821 891823782 989182 89182391 \
Expand All @@ -16,7 +18,17 @@ echo "Using genesis file $genesis"
echo "Edit scripts/multisim.sh to add new seeds. Keeping parameters in the file makes failures easy to reproduce."
echo "This script will kill all sub-simulations on SIGINT/SIGTERM (i.e. Ctrl-C)."

trap 'kill $(jobs -pr)' SIGINT SIGTERM
cleanup() {
local l_children
l_children=$(ps -o pid= --ppid $$)
echo "Stopping children ["${l_children}"] ..." >&2
kill -SIGSTOP ${l_children} || true
echo "Terminating children ["${l_children}"] ..." >&2
kill -TERM ${l_children} || true
exit 0
}

trap cleanup SIGINT SIGTERM

tmpdir=$(mktemp -d)
echo "Using temporary log directory: $tmpdir"
Expand Down

0 comments on commit 9036430

Please sign in to comment.