fork system call
Last updated
Last updated
Let's try the following code to see the effect of fork
!
Here is the sample output:
You will discover you have two lines of output! This can be explained by the behaviour of fork
. In the example, Process [8265] is the original process, and process [8266] is a newly spawned process (we call it child process).
fork
The child process will be spawned after fork
.
The child will continue executing the code after fork()
is returned, not from the beginning.
The parent still continues executing the same program.
Then How can we distinguish the parent and child process?