【发布时间】:2015-06-09 18:33:23
【问题描述】:
我有一个launch.sh 脚本,我用它在集群上提交
bsub $settings < launch.sh
这个launch.sh bash 脚本看起来简化如下:
function trap_with_arg() {
func="$1" ; shift
for sig ; do
echo "$ES Installing trap for signal $sig"
trap "$func $sig" "$sig"
done
}
function signalHandler() {
# do stuff depending in what stage the script is
}
# Setup the Trap
trap_with_arg signalHandler SIGINT SIGTERM SIGUSR1 SIGUSR2
./start.sh
mpirun process.sh
./end.sh
其中 process.sh 调用两个二进制文件(例如)为
./binaryA
./binaryB
我的问题如下:
集群已经将 SIGUSR1(在 SIGTERM 之前大约 10 分钟)发送到进程(我认为这是运行我的 launch.sh 脚本的 bash shell)。
目前我在launch.sh 脚本中捕获了这个信号并调用了一些信号处理程序。问题是,这个信号处理程序只有在运行命令完成后才会执行(至少我知道)(例如,可能是 mpirun process.sh 或 ./start.sh )
如何转发这些信号以使命令/二进制文件正常退出。例如转发到process.sh(mpirun,正如我所经历的那样,已经以某种方式转发了这些接收到的信号(它是如何做到的?)
转发信号的正确方法是什么(例如,也转发到二进制文件 binaryA, binaryB ?
我真的不知道如何做到这一点?让命令在后台执行,创建子进程?
感谢您的启发:-)
【问题讨论】:
标签: bash unix signals mpi cluster-computing