Fork () why not infinite output

why

int main(...) { fork(); printf("hello again\n"); exit(0); } 

not create an infinite number of procedural? I understood it as follows: the main process creates a child process, the child another, etc.

+4
source share
2 answers

Execution continues after fork in both the parent and the child; it does not restart the program.

+7
source

The parent process is "cloned" right at the execution point where fork() is called, and both processes go from there. The child process does not start by calling main () again.

+3
source

All Articles