Museum

Home

Lab Overview

Retrotechnology Articles

Online Manuals

⇒ vfork.bsd(2) — Domain/IX SR9.2.3

Media Vault

Software Library

Restoration Projects

Artifacts Sought

Related Articles

fork(2)

execve(2)

sigvec(2)

wait(2)

VFORK(2)

NAME

vfork − spawn new process in a virtual memory efficient way

USAGE

pid = vfork()
int pid;

DESCRIPTION

Vfork creates new processes without fully copying the address space of the old process, which conserves resources in a paged environment.  It is useful when the purpose of fork(2) is to create a new system context for an execve.  Vfork differs from fork in that the child borrows the parent’s memory and thread of control until a call to execve(2) or an exit (either by a call to exit(2) or abnormally.)  The parent process is suspended while the child is using its resources. 

Vfork returns zero in the child’s context and (later) the PID of the child in the parent’s context. 

Vfork can normally be used just like fork.  However, it is illegal to return from the procedure that called vfork while running in the child’s process, since vfork would be attempting to return to a non-existent stack frame.  Be careful, also, to call _exit rather than exit if you can’t execve, since exit will flush and close standard I/O channels, and thereby affect the parent processes’ standard I/O data structures.  (Even with fork, it is better not to call exit since buffered data is then flushed twice.) 

NOTES

This system call will be eliminated when proper system sharing mechanisms are implemented. 

To avoid possible deadlocks, processes that are children in the middle of a vfork are never sent SIGTTOU or SIGTTIN signals; rather, output or ioctls are allowed and input attempts result in an end-of-file indication. 

ERRORS

Vfork will fail and no child process will be created if one or more of the following is true:

[EAGAIN] The system-imposed limit on the total number of processes under execution would be exceeded. 

[EAGAIN] The system-imposed limit on the total number of processes under execution by a single user would be exceeded. 

RETURN VALUES

Same as for fork. 

RELATED INFORMATION

fork(2), execve(2), sigvec(2), wait(2),

Typewritten Software • bear@typewritten.org • Edmonds, WA 98026