我有一个脚本,在后台启动另一个脚本,然后终止它.我期待儿童脚本消失,但最终仍然设法打印一些输出.这是一个例子:
在脚本one.sh:
echo "this is one"
./two.sh &
sleep 1
pid=$!
kill $pid
echo "this was one"
Run Code Online (Sandbox Code Playgroud)
在脚本two.sh:
echo "this is two"
./three.sh
echo "this was two"
Run Code Online (Sandbox Code Playgroud)
在脚本three.sh:
echo "this is three"
sleep 5
echo "this was three"
Run Code Online (Sandbox Code Playgroud)
我跑了./one.sh,它应该在后台运行two.sh,然后运行three.sh但不在后台运行!得到的输出是:
this is one
this is two
this is three
this was one
this was three
Run Code Online (Sandbox Code Playgroud)
不应该在输出中出现"this is three",因为three.sh没有在后台运行而two.sh被one.sh终止了?您是否也可以向我指出任何文档,这些文档描述了进程在后台(而非)在后台运行时的行为以及终止时会发生什么?
非常感谢您的帮助!
| 归档时间: |
|
| 查看次数: |
3742 次 |
| 最近记录: |