我有以下问题:
我在脚本中放了3个进程
过程1 过程2 process3
我希望进程1和2同时运行,但它们都在进程3开始之前完成。
我想它类似于以下......但我不确定那个“等待”
#!/bin/sh
(
process1 &
process2 &
wait
process3
)
谢谢
的Fabio
答案 0 :(得分:3)
只需保存两个进程的pid并等待两个进程退出
#!/bin/bash
process1 &
pid1=$!
process2 &
pid2=$!
wait ${pid1}
echo "Return value of process1: $?"
wait ${pid2}
echo "Return value of process2: $?"
process3