xref: /openbsd-src/lib/libc/sys/vfork.2 (revision db3296cf5c1dd9058ceecc3a29fe4aaa0bd26000)
1.\"	$OpenBSD: vfork.2,v 1.14 2003/06/02 20:18:39 millert Exp $
2.\"	$NetBSD: vfork.2,v 1.8 1997/07/10 07:54:13 mikel Exp $
3.\"
4.\" Copyright (c) 1980, 1991, 1993
5.\"	The Regents of the University of California.  All rights reserved.
6.\"
7.\" Redistribution and use in source and binary forms, with or without
8.\" modification, are permitted provided that the following conditions
9.\" are met:
10.\" 1. Redistributions of source code must retain the above copyright
11.\"    notice, this list of conditions and the following disclaimer.
12.\" 2. Redistributions in binary form must reproduce the above copyright
13.\"    notice, this list of conditions and the following disclaimer in the
14.\"    documentation and/or other materials provided with the distribution.
15.\" 3. Neither the name of the University nor the names of its contributors
16.\"    may be used to endorse or promote products derived from this software
17.\"    without specific prior written permission.
18.\"
19.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
20.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
21.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
22.\" ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
23.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
24.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
25.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
26.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
27.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
28.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
29.\" SUCH DAMAGE.
30.\"
31.\"     @(#)vfork.2	8.1 (Berkeley) 6/4/93
32.\"
33.Dd June 30, 1997
34.Dt VFORK 2
35.Os
36.Sh NAME
37.Nm vfork
38.Nd spawn new process and block parent
39.Sh SYNOPSIS
40.Fd #include <unistd.h>
41.Ft pid_t
42.Fn vfork void
43.Sh DESCRIPTION
44.Fn vfork
45was originally used to create new processes without fully copying the address
46space of the old process, which is horrendously inefficient in a paged
47environment.
48It was useful when the purpose of
49.Xr fork 2
50would have been to create a new system context for an
51.Xr execve 2 .
52Since
53.Xr fork 2
54is now efficient, even in the above case, the need for
55.Fn vfork
56has diminished.
57.Fn vfork
58differs from
59.Xr fork 2
60in that the parent is suspended until the child makes a call to
61.Xr execve 2
62or an exit (either by a call to
63.Xr _exit 2
64or abnormally).
65.Pp
66.Fn vfork
67returns 0 in the child's context and (later) the PID of the child in
68the parent's context.
69.Sh RETURN VALUES
70Same as for
71.Xr fork 2 .
72.Sh SEE ALSO
73.Xr execve 2 ,
74.Xr fork 2 ,
75.Xr sigaction 2 ,
76.Xr wait 2
77.Sh HISTORY
78The
79.Fn vfork
80function call appeared in
81.Bx 2.9 .
82.Sh BUGS
83To avoid a possible deadlock situation, processes that are children
84in the middle of a
85.Fn vfork
86are never sent
87.Dv SIGTTOU
88or
89.Dv SIGTTIN
90signals; rather, output or
91.Xr ioctl 2
92calls are allowed and input attempts result in an end-of-file indication.
93