VFORK(2) UNIX Programmer's Manual VFORK(2) NAME vfork - spawn new process in an efficient way SYNOPSIS vfork() DESCRIPTION _V_f_o_r_k can be used to create new processes without fully copying the address space of the old process. It is useful 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_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 from the procedure which called _v_f_o_r_k while running in the child's context, since the eventual return from _v_f_o_r_k in the parent 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, since _e_x_i_t will flush and close standard I/O channels, and thereby mess up the parent process's standard 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.) Similarly when using the new signal mechanism of _s_i_g_s_e_t(3) mechanism be sure to call _s_i_g_s_y_s rather than _s_i_g_n_a_l(2). DIAGNOSTICS Same as for _f_o_r_k. SEE ALSO execve(2), fork(2), sigsys(2J), wait(2) BUGS This call is not portable to most dialects of UNIX. Users should not depend on the memory sharing semantics of _v_f_o_r_k as it could, in that case, be made synonymous to _f_o_r_k. To avoid a possible deadlock situation, processes which 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 5/26/83 1