VFORK(2) UNIX Programmer's Manual VFORK(2) NAME vfork - spawn new process in a virtual memory efficient way SYNOPSIS pid = vfork() int pid; DESCRIPTION _V_f_o_r_k can be used to create new processes without fully copying the address space of the old process, which is horrendously inefficient in a paged environment. It is use- ful when the purpose of _f_o_r_k(2) would have been to create a new system context for an _e_x_e_c_v_e. _V_f_o_r_k differs from _f_o_r_k in that the child borrows the parent's memory and thread of control until a call to _e_x_e_c_v_e(2) or an exit (either by a call to _e_x_i_t(2) or abnormally.) The parent process is suspended while the child is using its resources. _V_f_o_r_k returns 0 in the child's context and (later) the pid of the child in the parent's context. _V_f_o_r_k can normally be used just like _f_o_r_k. It does not work, however, to return while running in the childs context from the procedure that called _v_f_o_r_k since the eventual return from _v_f_o_r_k would then return to a no longer existent stack frame. Be careful, also, to call __e_x_i_t rather than _e_x_i_t if you can't _e_x_e_c_v_e, since _e_x_i_t will flush and close standard I/O channels, and thereby mess up the parent processes stan- dard I/O data structures. (Even with _f_o_r_k it is wrong to call _e_x_i_t since buffered data would then be flushed twice.) SEE ALSO fork(2), execve(2), sigvec(2), wait(2), DIAGNOSTICS Same as for _f_o_r_k. BUGS This system call will be eliminated when proper system shar- ing mechanisms are implemented. Users should not depend on the memory sharing semantics of _v_f_o_r_k as it will, in that case, be made synonymous to _f_o_r_k. To avoid a possible deadlock situation, processes that are children in the middle of a _v_f_o_r_k are never sent SIGTTOU or SIGTTIN signals; rather, output or _i_o_c_t_ls are allowed and input attempts result in an end-of-file indication. Printed 11/26/99 June 30, 1985 1