1
我想获得我正在等待并返回的进程的退出代码。 我有一个名为script.sh脚本,看起来像这样:Bash获取等待进程的退出代码
#!/bin/bash
path="/PATH/TO/SCRIPT/another_script.sh"
$path
wait
cleanUpFunction
如何从script.sh的another_script.sh的退出代码返回?
我想获得我正在等待并返回的进程的退出代码。 我有一个名为script.sh脚本,看起来像这样:Bash获取等待进程的退出代码
#!/bin/bash
path="/PATH/TO/SCRIPT/another_script.sh"
$path
wait
cleanUpFunction
如何从script.sh的another_script.sh的退出代码返回?
你是不是在后台运行another_script.sh
,所以你不需要wait
在所有。
another_script.sh
exit_code=$?
如果被,虽然的wait
退出状态是后台进程的退出状态。
another_script.sh &
# Do some other stuff
wait
exit_code=$?