我正在分叉一堆进程,我想为我的主要原始进程创建一个“屏障”,以等待所有其他进程完成。代码流如下所示:
#...the main thread is executing now, and reaches this foreach loop:
foreach arg (myArgs)
some_command arg & #these are the processes being forked off
end
#I want the main thread to WAIT here until all the above processes finish!
#... More code below here for the main thread to continue with
我不确定我想要什么同步原语,甚至不确定在 unix shell 环境中有什么可用的。也许像主线程的障碍?
谢谢你的帮助。