Thursday, 4 December 2014


#include"myHeader.h"
int data=0;
main(int argc,char **argv)
{
int ret;
ret=vfork();
if(ret==0)
{
printf("in child process:data=%d\n",data);
data++;
printf("in child process:data(inc)=%d\n",data);
}
else
{
printf("in parent process:data=%d\n",data);
data++;
printf("in parent process:data(inc)=%d\n",data);
}
exit(0);
}
OutPut:
madan@madan-Lenovo-G570:~/madan/osconcepts$ vi ex10.c
madan@madan-Lenovo-G570:~/madan/osconcepts$ cc ex10.c
madan@madan-Lenovo-G570:~/madan/osconcepts$ ./a.out
in child process:data=0
in child process:data(inc)=1
in parent process:data=1
in parent process:data(inc)=2