Write a c program, create a global variable and try to increment its value for child & parent
#include<stdio.h>
#include<unistd.h>
int i;
int main()
{
int ret;
printf("global variable before fork:%d \n",i);
ret = fork();
if(ret0)
{
i++;
printf("Parent Process! and incremented global variable:%d \n",i);
}
return 0;
}
Sign up here with your email
ConversionConversion EmoticonEmoticon