When a process executes a fork command it’s whole heap, stack and data is duplicated into the child process, it created.
Things to note
- The Program Counter value is also copied into the child process. Thus, the program execution is resumed from where the parent issued the fork command
- The fork command returns the parent (the process calling it) the child id and to child an ID of 0
Origin | Fork Command |
---|
Child Process | Return 0 |
Parent Process | Returns > 0 |
Error While Creating | Returns -1 |
Examples - Multiple Forks