I want to create three child processes from a child process of the main process (P0). So something like --> 

```
P0 -> P1 ->P2  
             ->P3
             ->P4

```

However, whenever I run it I get (for the processes P2,P3,P4) the ppid of the main process (ppid = 1). 

I am using fork() system call in order to create the children and the implementation of the program is in C.

```
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>

int main()
{
    int i, pid1, pid2;
    pid1 = fork();
    printf("Pid1 pid -> %d ppid -> %d\n",getpid(),getppid());
    if(pid1 != 0)
    {
        pid2 = fork();
        printf("Pid2 pid -> %d ppid -> %d\n",getpid(),getppid());
        if(pid2 == 0)
        {
            for(i=2; i<5; i++)
            {
                //if(fork()==0)
                //{
                    printf("Child %d pid -> %d Parent -> %d\n",i+1,getpid(),getppid());
                //}
                exit(0);
            }
        }
        else 
        {
            printf("Pid2 father process \n");
        }  
    }
    else 
    {
        printf("Pid1 child process\n");

    }
}

```