View Single Post
Ambitious contributor
9Jan2010,10:05  
venami's Avatar
When the code is executed, the first printf() is executed once before another process is created using fork(). After fork(), the new process gets the copy of the code part after fork(). So each process(parent and child) executes the second printf() once each.

This is how a fork()-ed process works.