From c68dee26ad864ff344f4d77da3f2148e164dca0a Mon Sep 17 00:00:00 2001 From: Gabriel Corona Date: Tue, 25 Aug 2015 09:35:48 +0200 Subject: [PATCH] smpirun: Raise the same signal we received --- src/smpi/smpirun.in | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) diff --git a/src/smpi/smpirun.in b/src/smpi/smpirun.in index e9e2b431ec..18a29d853c 100755 --- a/src/smpi/smpirun.in +++ b/src/smpi/smpirun.in @@ -69,6 +69,8 @@ HOSTFILETMP=0 unset pid +trapped_signals="HUP INT QUIT ILL ABRT SEGV FPE ALRM TERM USR1 USR2 BUS" + smpirun_cleanup() { if [ -z "${KEEP}" ] ; then @@ -92,17 +94,28 @@ smpirun_cleanup() } smpirun_trap() { + local sig + sig="$1" + + # Cleanup and kill the child process: smpirun_cleanup if ! [ -z "$pid" ]; then kill -TERM $pid fi unset pid - trap - HUP INT QUIT ILL ABRT SEGV FPE ALRM TERM USR1 USR2 BUS + + # Raise the same signal again (remove the traps first): + trap - $trapped_signals + kill -$sig $$ + + # This should never happen: + kill -ABRT $$ kill -TERM $$ - exit 128 } -trap smpirun_trap HUP INT QUIT ILL ABRT SEGV FPE ALRM TERM USR1 USR2 BUS +for s in $trapped_signals; do + trap "smpirun_trap $s" $s +done while true; do case "$1" in -- 2.20.1