vfork.2

来自「<B>Digital的Unix操作系统VAX 4.2源码</B>」· 2 代码 · 共 80 行

2
80
字号
.\" SCCSID: @(#)vfork.2	8.1	9/11/90.TH vfork 2.SH Namevfork \- spawn new process in a virtual memory-efficient way.SH Syntax.B pid = vfork().br.B int pid;.SH Description.NXR "vfork system call".NXR "process" "creating efficiently".NXA "fork system call" "vfork system call".NXA "vfork system call" "fork system call"The.PN vforkcan be used to create new processes without fully copying the addressspace of the old process, which is inefficient in a pagedenvironment.  It is useful when the purpose of .PN fork would have been to create a new system context for an.PN execve .The.PN vforksystem call differs from.PN forkin that the child borrows the parent's memory and thread ofcontrol until a call to .PN execve or an exit (either by a call to.MS exit 2or abnormally.)The parent process is suspended while the child is using its resources..PPThe.PN vforksystem call returns a value of zero (0) in the child's context and,later, the pid of the child inthe parent's context..PPThe.PN vforksystem callcan normally be used just like.PN fork .It does not work, however, to return while running in the childs contextfrom the procedure which called.PN vfork ,because the eventual return from.PN vforkwould then return to a nonexistent stack frame.Be careful, also, to call.I _exitrather than.I exitif you cannot call.PN execve ,because.I exitwill flush and close standard I/O channels and thereby cause problems in theparent process's standard I/O data structures.Even with.PN forkit is wrong to call.IR exit ,because buffered data would then be flushed twice..SH RestrictionsTo avoid a possible deadlock situation,processes which are children in the middleof a.PN vforkare never sent SIGTTOU or SIGTTIN signals.  Rather,output or.IR ioctl sare allowed, and input attempts result in an end-of-file indication..SH DiagnosticsSame as for.PN fork ..SH See Alsoexecve(2), fork(2), sigvec(2), wait(2)

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?