Search code examples
cunixbsd

Vfork() and more corruption


my question is on execution what will happen to parent stack?

main()
{
    f();
    g();
}
f()
{
   vfork();
}
g()
{ 
    int blast[100],i;
    for(i=0;i<100;i++)
        blast[i]=i;
}

Solution

  • The behavior is undefined as per http://pubs.opengroup.org/onlinepubs/009695399/functions/vfork.html

    the behavior is undefined if the process created by vfork() [...] returns from the function in which vfork() was called [...]