xref: /386bsd/usr/share/man/cat2/vfork.0 (revision a2142627)
1VFORK(2)                  386BSD Programmer's Manual                  VFORK(2)
2
3NNAAMMEE
4     vvffoorrkk - spawn new process in a virtual memory efficient way
5
6SSYYNNOOPPSSIISS
7     ##iinncclluuddee <<uunniissttdd..hh>>
8
9     _i_n_t
10     vvffoorrkk(_v_o_i_d)
11
12DDEESSCCRRIIPPTTIIOONN
13     VVffoorrkk() can be used to create new processes without fully copying the
14     address space of the old process, which is horrendously inefficient in a
15     paged environment.  It is useful when the purpose of fork(2) would have
16     been to create a new system context for an execve.  VVffoorrkk() differs from
17     fork in that the child borrows the parent's memory and thread of control
18     until a call to execve(2) or an exit (either by a call to exit(2) or
19     abnormally.)  The parent process is suspended while the child is using
20     its resources.
21
22     VVffoorrkk() returns 0 in the child's context and (later) the pid of the child
23     in the parent's context.
24
25     VVffoorrkk() can normally be used just like fork.  It does not work, however,
26     to return while running in the childs context from the procedure that
27     called vvffoorrkk() since the eventual return from vvffoorrkk() would then return
28     to a no longer existent stack frame.  Be careful, also, to call _exit
29     rather than exit if you can't execve,  since exit will flush and close
30     standard I/O channels, and thereby mess up the parent processes standard
31     I/O data structures.  (Even with fork it is wrong to call exit since
32     buffered data would then be flushed twice.)
33
34SSEEEE AALLSSOO
35     fork(2),  execve(2),  sigvec(2),  wait(2),
36
37DDIIAAGGNNOOSSTTIICCSS
38     Same as for fork.
39
40BBUUGGSS
41     This system call will be eliminated when proper system sharing mechanisms
42     are implemented.  Users should not depend on the memory sharing semantics
43     of vfork as it will, in that case, be made synonymous to fork.
44
45     To avoid a possible deadlock situation, processes that are children in
46     the middle of a vvffoorrkk() are never sent SIGTTOU or SIGTTIN signals;
47     rather, output or ioctl(2) calls are allowed and input attempts result in
48     an end-of-file indication.
49
50HHIISSTTOORRYY
51     The vvffoorrkk function call appeared in 3.0BSD.
52
534th Berkeley Distribution       March 10, 1991                               1
54
55
56
57
58
59
60
61
62
63
64
65
66
67