VFORK

Section: MINTLIB LIBRARY FUNCTIONS (3)
Updated: 3 March 1993
Index Return to Main Contents
 

NAME

vfork - spawn new process in a memory efficient way  

SYNOPSIS

#include <unistd.h>

int vfork(void);
 

DESCRIPTION

vfork can be used to create new processes without fully copying the address space of the parent process, which is unnecessary in many cases. It is useful when the only purpose of fork would have been to create a new process just in order to do an exec.. call. vfork differs from fork in that the child borrows the parent's memory and thread of control until a call to exec.., or an exit (either by a call to _exit or abnormally). The parent process is suspended while the child is using its resources. vfork returns zero to the child and (later) the process ID of the child to the parent.  

SEE ALSO

exec..(3), fork(3), tfork(3), wait(3)  

NOTES

The child should never return from the procedure that called vfork, since that will mess up the stack frame for the parent on its return from vfork. The vfork call is not available in UN*X System V.3. It will disappear from SunOS in the future (in fact, it would have disappeared if it weren't for the program mentioned below). So, if you want to write portable code, fork, don't vfork. Changes the child makes to the parents' variables will have effect on the parent. Do not rely on this, since it is a disgusting habit. (Presumably, this is why the Berkeley C-Shell has been implemented this way.)
 

Index

NAME
SYNOPSIS
DESCRIPTION
SEE ALSO
NOTES

This document was created by man2html, using the manual pages.
Time: 08:59:09 GMT, February 14, 2025