Mail Archives: cygwin-developers/1998/06/30/14:48:30
> Hello.,
> vfork appears to be a simple wrapper over fork(). However, as per the
> vfork man page, the child process uses the parent's memory. Your
> implementation will obviously work when vfork is used as a faster fork
> because it will yield the correct behavior. However, it is possible to
> write a program that uses vfork that gives differeent results on unix
> than on nt+cygwin32 library. Please let me know if my understanding is
> correct. Thanks, -sashi. P.S: Please reply directly to me as I am not
> on the mailing list.
As other's have pointed out, you cannot depend on vfork()'s
semantics when altering the child's memory prior to an exec.
On the other hand, it seems that a vfork() that didn't call
the real fork could be made much faster in cygwin.
- Allocate a new process structure for the new process
- spawn a new thread for the new process
- wait until the new thread terminates
- continue
while the new thread is running, make sure it will use the
context of the new process table entry. When an exec is
encountered, notice that the process is really a vfork'ed
process and instead of terminating the current process after
the new CreateProcess, simply wake up the vfork parent
and terminate the thread.
This would avoid a lot of expensive stuff done in fork().
A side affect of this would be the more traditional (and
somewhat kludgy) behavior of vfork.
Tim N.
- Raw text -