# Fork() execution and number of processes

If a process executes the following code

fork();
fork();
fork();


The total number of child processes created is given as 7 by a text book. But how does that happen

fork generates 2 processes right? Are both the processes referred to as child processes? One process is the parent parent and one is the child right? Even if both the processes are referred to as child processes,2*3=6? The main process is not a child process,how does the number 7 come into the picture.

Update:

• You should use it practically to see how it works. Then it will be easy for you to understand. – Deep Joshi Sep 18 '18 at 9:22
• Each fork command generates a new process and the created process starts executing from the subsequent line of code. So in total, seven child processes are created - eight including the original one. – Gokul Sep 18 '18 at 9:54
• @Gokul if each fork command generates a single process,There will be a total of 4 processes, right? – techno Sep 18 '18 at 9:57
• No, that's not how it works. Check this link. – Gokul Sep 18 '18 at 10:10