Reputation: 107
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;
}
Upvotes: 0
Views: 149
Reputation: 1
In practice, vfork
is not very useful any more. Read its vfork man page for Linux, which says that POSIX.1-2008 removes the specification of vfork(). the behavior is practically nearly the same as for fork
(except that the parent is suspended). So I'll bet that practically, vfork
is nearly like fork
today. But all the programs I've read in the last ten years used fork
not vfork
(because the lazy copy on write paging behavior is efficient enough today).
Upvotes: -2
Reputation: 16888
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 [...]
Upvotes: 3