From: newsham AT lava DOT net (Tim Newsham) Subject: Re: vfork in cygwin32 30 Jun 1998 14:48:30 -0700 Message-ID: References: <199806290739 DOT AAA20061 AT dlsun342 DOT oracle DOT com> Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit To: schandra AT dlsun342 DOT us DOT oracle DOT com (Sashikanth Chandrasekaran) Cc: cygwin32-developers AT cygnus DOT com, schandra AT dlsun342 DOT us DOT oracle DOT com > 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.