Home > Back-end >  About GCC - O2 vfork function is not correct
About GCC - O2 vfork function is not correct

Time:04-01


 
# include & lt; Stdio. H>
# include & lt; Unistd. H>
Int main (void)
{
Int x=0;
Int pid=vfork ();
if (! Pid)
{
Printf (" the child process output x: % d \ n ", x);
X++;
exit(0);
}
The else
{
Printf (" the parent process output x: % d \ n ", x);
X++;
}
return 0;
}


 
The results
The child process output x: 0
The parent process output x: 0
The Program ended with exit code: 0


The parent should output 1, the GCC optimizations set - O0
  • Related