I am trying to have a program that uses multiple forks.
I used this example to get myself started
Multiple fork() Concurrency
it works perfectly as is. However, when I try to add a print statement in the child like this:
if ((p = fork()) == 0) {
// Child process: do your work here
printf("child %i\n", ii);
exit(0);
}
The process never finishes. How can I do stuff in the child and get the parent to still finish execution of the program?