<html><body style="word-wrap: break-word; -webkit-nbsp-mode: space; line-break: after-white-space;" class="">You could also choose to propagate the signal to the child process of test.slurm yourself:<div class=""><br class=""></div><div class=""><br class=""></div><blockquote style="margin: 0 0 0 40px; border: none; padding: 0px;" class=""><div class="">#!/bin/bash</div><div class="">#SBATCH --job-name=test</div><div class="">#SBATCH --ntasks-per-node=1</div><div class="">#SBATCH --nodes=1</div><div class="">#SBATCH --time=00:03:00</div><div class="">#SBATCH --signal=B:SIGINT@30</div><div class=""><br class=""></div><div class=""># This example works, but I need it to work without "B:" in --signal options, so I want test.sh receives the SIGINT signal and not test.slurm</div><div class=""><br class=""></div><div class="">sig_handler()</div><div class="">{</div><div class="">         echo "BATCH interrupted"</div><div class="">         if [ -n "$child_pid" ]; then</div><div class="">             kill -INT $child_pid</div><div class="">         fi</div><div class="">}</div><div class=""><br class=""></div><div class="">trap 'sig_handler' SIGINT</div><div class=""><br class=""></div><div class="">/home/user/test.sh &</div><div class="">child_pid=$!</div><div class="">wait $child_pid</div><div class="">exit $?</div></blockquote><div class=""><br class=""></div><div class=""><br class=""></div><div class="">and</div><div class=""><br class=""></div><div class=""><br class=""></div><blockquote style="margin: 0 0 0 40px; border: none; padding: 0px;" class=""><div class="">#!/bin/bash</div><div class=""><br class=""></div><div class="">function sig_handler()</div><div class="">{</div><div class="">         echo "Executable interrupted"</div><div class="">         exit 2</div><div class="">}</div><div class=""><br class=""></div><div class="">trap 'sig_handler' SIGINT</div><div class=""><br class=""></div><div class="">echo "BEGIN"</div><div class="">sleep 200 &</div><div class="">wait</div><div class="">echo "END"</div></blockquote><div class=""><br class=""><br class="">Having your signal handler in test.slurm "exit 2" signals the end of the job, so the child processes will be terminated whether they've hit their own signal handler yet or not.  Signaling the child then returning control in test.slurm to wait and reap the child's exit code and "exit $?" actually gives the child time to do cleanup and influence the final exit code of the job.<br class=""><br class=""><br class=""><br class=""><br class=""><blockquote type="cite" class="">On Apr 21, 2020, at 06:13 , Bjørn-Helge Mevik <<a href="mailto:b.h.mevik@usit.uio.no" class="">b.h.mevik@usit.uio.no</a>> wrote:<br class=""><br class="">Jean-mathieu CHANTREIN <<a href="mailto:jean-mathieu.chantrein@univ-angers.fr" class="">jean-mathieu.chantrein@univ-angers.fr</a>> writes:<br class=""><br class=""><blockquote type="cite" class="">But that is not enough, it is also necessary to use srun in<br class="">test.slurm, because the signals are sent to the child processes only<br class="">if they are also children in the JOB sense.<br class=""></blockquote><br class="">Good to know!<br class=""><br class="">-- <br class="">Cheers,<br class="">Bjørn-Helge Mevik, dr. scient,<br class="">Department for Research Computing, University of Oslo<br class=""></blockquote><br class=""></div></body></html>