in reply to Re^2: fork(): when parent exits, what happens to child?
in thread fork(): when parent exits, what happens to child?

Even if you turn off the buffering you should not expect more than one number every two seconds to arrive in data1.txt. Again because of 'sleep 2'.

Of course! So then the rule is: when a parent terminates, the child keeps on executing.

  • Comment on Re^3: fork(): when parent exits, what happens to child?

Replies are listed 'Best First'.
Re^4: fork(): when parent exits, what happens to child?
by rowdog (Curate) on Mar 28, 2010 at 03:30 UTC

    So then the rule is: when a parent terminates, the child keeps on executing.

    Indeed, you've forked a new process, but well behaved parents wait (or waitpid) on their children so they don't turn into zombies.