|
|
1.1 ! root 1: .TH VFORK 2 "2 July 1983" ! 2: .UC 4 ! 3: .SH NAME ! 4: vfork \- spawn new process in a virtual memory efficient way ! 5: .SH SYNOPSIS ! 6: .B pid = vfork() ! 7: .br ! 8: .B int pid; ! 9: .SH DESCRIPTION ! 10: .I Vfork ! 11: can be used to create new processes without fully copying the address ! 12: space of the old process, which is horrendously inefficient in a paged ! 13: environment. It is useful when the purpose of ! 14: .IR fork (2) ! 15: would have been to create a new system context for an ! 16: .IR execve . ! 17: .I Vfork ! 18: differs from ! 19: .I fork ! 20: in that the child borrows the parent's memory and thread of ! 21: control until a call to ! 22: .IR execve (2) ! 23: or an exit (either by a call to ! 24: .IR exit (2) ! 25: or abnormally.) ! 26: The parent process is suspended while the child is using its resources. ! 27: .PP ! 28: .I Vfork ! 29: returns 0 in the child's context and (later) the pid of the child in ! 30: the parent's context. ! 31: .PP ! 32: .I Vfork ! 33: can normally be used just like ! 34: .I fork. ! 35: It does not work, however, to return while running in the childs context ! 36: from the procedure which called ! 37: .I vfork ! 38: since the eventual return from ! 39: .I vfork ! 40: would then return to a no longer existent stack frame. ! 41: Be careful, also, to call ! 42: .I _exit ! 43: rather than ! 44: .I exit ! 45: if you can't ! 46: .IR execve , ! 47: since ! 48: .I exit ! 49: will flush and close standard I/O channels, and thereby mess up the ! 50: parent processes standard I/O data structures. ! 51: (Even with ! 52: .I fork ! 53: it is wrong to call ! 54: .I exit ! 55: since buffered data would then be flushed twice.) ! 56: .SH SEE ALSO ! 57: fork(2), execve(2), sigvec(2), wait(2), ! 58: .SH DIAGNOSTICS ! 59: Same as for ! 60: .IR fork . ! 61: .SH BUGS ! 62: This system call will be eliminated when proper system sharing ! 63: mechanisms are implemented. ! 64: Users should not depend on the memory ! 65: sharing semantics of ! 66: .I vfork ! 67: as it will, in that case, be made synonymous to ! 68: .IR fork . ! 69: .PP ! 70: To avoid a possible deadlock situation, ! 71: processes which are children in the middle ! 72: of a ! 73: .I vfork ! 74: are never sent SIGTTOU or SIGTTIN signals; rather, ! 75: output or ! 76: .IR ioctl s ! 77: are allowed ! 78: and input attempts result in an end-of-file indication.
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.