/*Code open-sourced by http://codejar-lab.in This is only for study purpose only and if you found any error use own logic to correct it so dont comment error. */ #include<stdio.h>How to run it?int main() { int PId; PId = fork(); if ( PId == 0 ) { printf("Child Here.....\n"); sleep(20); printf(" Parent Id : %d\n",getppid()); printf(" My Id : %d\n",getpid()); } else { printf("Parent Here.....\n"); printf(" My Child : %d\n",PId); printf(" My Id : %d\n",getpid()); printf(" My Parent : %d\n",getppid()); } }
$gcc file.c
$./a.out
c programming examples for novices
c sample code Recursive directory walk