I'm making a little program using a lot of forks. The first parent have to wait for everychildren. For only one child it's easy, there is the child-end signal (SIGCLHD). But what if my first child ends before the last child? My main program runs before the end of everychilds and I need the main program wait for children.
Each child ends with an execution of another program, that explain why I can't synchronize with something like semaphores.
// Working pretty good
execvp(
c->command_name, /* program to execute */
c->argv /* argv of program to exécuter */
);
Here is my "fork-structure":
main
|
|------
| |
| |
| |------
| | |
| EOE |
| |
| EOE
|
|
EOE
Legend:
- EOE means "End Of Execution
- The line top-bot is the timeline
- Each new step to the left is a new child.
- Each vertical bar represents the execution of a bar
Thanks!