#include #include int main() { pid_t pid, pid1, father; printf("i am in the main program \n\n"); pid=fork(); if(pid==0) /*i am the child*/ { printf("\n------------------------------------------------"); printf("\n i am the child since my pid is 0\n"); pid1=getpid(); father=getppid(); printf("\ngetpid():=%d",pid1); printf("\nfork() returned my pid as:=%d", pid); printf("\ngetppid():=%d\n\n\n", father); } else /*am the father*/ { printf("\n------------------------------------------------"); printf("\nI am the father\n"); pid1=getpid(); father=getppid(); printf("\ngetpid():=%d", pid1); printf("\nfork() returned my pid as:=%d",pid); printf("\ngetppid():=%d\n\n\n\n",father); } } /* OUTPUT i am in the main program ------------------------------------------------ I am the father getpid():=1030 fork() returned my pid as:=1031 getppid():=683 ------------------------------------------------ I am the child since my pid is 0 getpid():=1031 fork() returned my pid as:=0 getppid():=1 */