vfork issue
I have this issue with a sample program that I run on solaris 5.8 using vfork(). What I found is the memory of the main process is not shared with the vforked process. Any changes (stack/data) which is done in the child should get reflected in the parent.
Using g++/gcc version 2.95.2
Any help in this is hghly appreciated.
I don't believe this behaviour is guaranteed. Some implementations may do this.
But you can't assume it.
vfork is simply an optimisation intended for the vfork then immediately execve case.
The behaviour if you do something other than vfork then immediately call execve is undefined.
Its all in the vfork man page.
That being said, it works for me using gcc on solaris 8,9,10.
But only if I don't optimise the compile.
Presumably the optimiser puts the variable into a register which is not shared between contexts...
You should be able to force a variable to not be put in a register by marking it volatile.
But do you really want to play those kind of games.
Any program relying on those semantics is buggy.