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