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=$?