Using vfork() -vs fork()

Dave Hammond daveh at marob.masa.com
Sat Jul 22 11:32:30 AEST 1989


Pertaining to vfork() and fork() usage in Berkely-specific C programs:

>From what I can glean from the manual, the advantages of vfork() over
fork() are (1) virtual memory efficiency and (2) shared access to parent
memory, data structures, etc.  until an execv().

The disadvantage seems to be that returning to the parent context while
the childs context still exists does not work.  Does this mean that
spawning an asynchronous process via vfork() is not possible?

My application wants to spawn children to:
(1) execute adhoc subtasks (like `system("command")' ).
(2) execute adhoc subtasks asynchronously (like `system("command &")' ).
(3) execute cooperative subtasks for data sharing (like `popen("command")' ).

My feeling is that vfork() is less appropo for this application than
fork().  Am I offbase about this?

Can someone provide concrete examples of where I'd want to use vfork(),
rather than fork()?

--
Dave Hammond
daveh at marob.masa.com



More information about the Comp.unix.questions mailing list