# Spawn a child process:(dosmth) & pid=$!# in the background, sleep for 10 secs then kill that process(sleep 10 && kill -9 $pid) &或者也可以得到出口代码:# Spawn a child process:(dosmth) & pid=$!# in the background, sleep for 10 secs then kill that process(sleep 10 && kill -9 $pid) & waiter=$!# wait on our worker process and return the exitcodeexitcode=$(wait $pid && echo $?)# kill the waiter subshell, if it still runskill -9 $waiter 2>/dev/null# 0 if we killed the waiter, cause that means the process finished before the waiterfinished_gracefully=$?