This is the mail archive of the
mailing list for the Cygwin project.
- To: firstname.lastname@example.org
- Subject: vfork implementation
- From: Chris Faylor <email@example.com>
- Date: Tue, 27 Jul 1999 20:10:29 -0400
Ok. I've got an experimental vfork implementation working. I worked
out most of it in the air between Boston and Sunnyvale last week.
The way it works is to fill in a structure with some frame information,
returning from vfork with a value of 0. The assumption is that the
calling program will 1) not return from the function which called the
vfork (which is true for the BSD vfork implementation) and 2) quickly
call some exec function.
When an exec function is invoked, it checks the above structure to see
if the process is in a 'vforked' state and changes any exec to a
spawn*(P_NOWAIT). The spawn* function then invokes the "execed" program
as a subprocess and longjmps back to vfork, where the stack is fixed up
and vfork returns with the pid of the newly execed process.
If the exec* function fails, and the program exits, then a true fork is
done which immediately exits with the exit value. The parent process
then sees the pid of this process on return from vfork.
This implementation has at least one problem. If you do a 'getpid()' in
the child process you get the pid of the parent not the child. This is
not insurmountable but I am wondering how big a problem this might be.
Does anyone have any idea?
In benchmarks, this vfork is *at least* twice as fast as a normal fork.
So what do you think? Is this good enough to go into the mythical next
net release (B21)? Should I make it a cygwin option, i.e.