The child process has a process ID of zero, and the parent process has a process ID of not zero.
Not quite. The return value from fork is zero for the new (child) process (because it can get the parent's process ID via getppid) while the return value from fork for the old (parent) process is the (non-zero) process ID of the child.
Both parent and child share data structures
They each get their own copy of the data structures, so they don't really share them. For efficiency reasons, most implementations of fork will actually allow the parent and child to share the data structures until one process tries to modify a data structure. At that point, the copying is done (of the page(s) of memory containing the data that was trying to be modified).
- tye (but my friends call me "Tye")In reply to (tye)Re: Forked off!
by tye
in thread Forked off!
by larryk
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |