vfork() (was Re: RS6000 questions/comments)

Sean Eric Fagan sef at kithrup.COM
Sat Jun 29 17:29:30 AEST 1991


In article <351 at devnull.mpd.tandem.com> lance at mpd.tandem.com (Lance Hartmann) writes:
>"...only legitimate use...child will execute before parent"???  The MAIN reason
>to use vfork() is when it is desired to spawn a child that does nothing
>but an execve().  With this scenario, it is unnecessary to copy the
>address space of the parent, so using vfork() is much more efficient.

Gee, on my system, which does not have vfork(), a fork() does not cause the
address space of the parent to be copied.  That's what COW is for.

vfork() is a hack.  Period.  The history I have gotten was that it was done
because the VAXen Berkeley had at the time were not completely capable of
doing COW (bug in the microcode, apparantly), therefore, to ease fork()'s
cost, they created a new system call.

For extremely large processes, many processors and their implementations
will have some problems with using COW forks that vfork() would handle.
However, this need not be the case (I can think of a few tricks that can be
done, and if you throw in hardware assist there are an amazing number of
things you can do).

>Also, don't forget to use _exit() (note the leading underscore '_') INSTEAD
>of exit() in the event the execve() fails so that you don't hose the parent's
>stdio.

Yep.  That's what happens when you use the hack vfork().

-- 
Sean Eric Fagan  | "What *does* that 33 do?  I have no idea."
sef at kithrup.COM  |           -- Chris Torek
-----------------+              (torek at ee.lbl.gov)
Any opinions expressed are my own, and generally unpopular with others.



More information about the Comp.unix.aix mailing list