vfork \- spawn new process in a virtual memory efficient way
can be used to create new processes without fully copying the address
space of the old process, which is horrendously inefficient in a paged
environment. It is useful when the purpose of
(2) would have been to create a new system context for an
differs from fork in that the parent's memory and thread of control run in
the child's system context till a call to
The parent's process slot is suspended while it runs in the child's.
returns 0 in the child's context and (later) the pid of the child in
can normally be used just like
It does not work, however, to return while running in the childs context
from the procedure which called
since the eventual return from
would then return to a no longer existant stack frame.
Be careful, also, to call
will flush and close standard I/O channels, and thereby mess up the
parent processes standard I/O data structures. (Even with
since buffered data would then be flushed twice.)
fork(2), exec(2), wait(2),
were implemented by a mechanism similar to copy-on-write.
The current system does not support this mechanism, however, necessitating