I'm trying to fork 3 different child processes from a parent (and running this on a UNIX box), and I want to have this requirement :
The parent must wait till all the 3 children processes have finished executing.
I'm using wait for the same .. Here's the code snippet :
#include <unistd.h>
#include <sys/signal.h>
#include <sys/types.h>
#include <sys/wait.h>
int main()
{
int stat;
/* ... */
At last, in the parent, I do this :
wait (&stat);
/* ... */
return 0;
}
Question :
Do I need to call wait thrice or does a single call suffice?
I need to know how this works..
You have to issue three waits. Each wait blocks until a child exits or doesn't block if a child has already exited. See wait.
You have to wait three times.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With