#include"myHeader.h" int data=10; main() { int status; if(fork()==0) { printf("data in child process:%d\n",data); sleep(5); printf("child exiting...\n"); } else { printf("data in parent process:%d\n",data); wait(&status); printf("parent exiting....\n"); //sleep(2); } }OutPut:
madan@madan-Lenovo-G570:~/madan/osconcepts$ cc ex23.c madan@madan-Lenovo-G570:~/madan/osconcepts$ ./a.out data in parent process:10 data in child process:10 child exiting... parent exiting....