[英]bash shell script terminates after program execution in loop
The below simplified (printf/echo/cd/sleep/progressbar commands that do not matter left out) bash shell script terminates after the first execution of the binary. 下列简化的(printf / echo / cd / sleep / progressbar命令无关紧要)bash shell脚本在第一次执行二进制文件后终止。 Why is this? 为什么是这样? Can I do or test anything without modifying the binary itself (Can only do this to certain limited extent) ? 我可以在不修改二进制文件本身的情况下做任何事情或测试什么(只能在一定程度上进行)?
PROGRESS=0
SIMULATIONS=30
for number in $(seq ${PROGRESS} ${SIMULATIONS})
do
echo 'INB4 TERMINATION'
nohup ./binary -someflag
# do other stuff next
echo 'NEVER GETS HERE'
done
I have read up on traps
but adding this line: 我已经阅读了traps
但添加了以下内容:
trap "echo 'trap invoked'; exit" SIGHUP SIGINT SIGTERM
nohup
or not does not seem to matter. 是否使用nohup
似乎无关紧要。 what the binary does 二进制文件做什么
It runs a 3D robot simulation experiment (which itself forks once to run 2 robot simulator processes in parallel (using the C/C++ system() command). Also each robot simulator launches a thread for each of 16 robot controllers). 它运行一个3D机器人仿真实验(它本身分叉一次以并行运行2个机器人模拟器进程(使用C / C ++ system()命令)。每个机器人模拟器还为16个机器人控制器中的每个控制器启动一个线程)。 So the binary is the parent process of 32 threads. 因此,二进制文件是32个线程的父进程。 If that makes sense at all, does it matter? 如果那完全有意义,那有关系吗?
I just found out what was causing it. 我才发现是什么原因造成的。 I pulled a progress bar bash function from somewhere and called that function after the ./binary. 我从某个地方提取了进度条bash函数,并在./binary之后调用了该函数。 This was causing my script to stop... I just didn't thought it was the cause earlier, because it didn't output anything. 这导致我的脚本停止运行……我只是没有想到这是更早的原因,因为它没有输出任何内容。 That was a stupid assumption. 那是一个愚蠢的假设。
For completeness, this is the progress bar I was using: https://github.com/fearside/ProgressBar/ 为了完整起见,这是我使用的进度条: https : //github.com/fearside/ProgressBar/
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.