Messages in this thread | | | Subject | Re: vfork | From | (Eric W. Biederman) | Date | 01 Nov 1999 14:00:21 -0600 |
| |
Andries.Brouwer@cwi.nl writes:
> People tell me that vfork() no longer is equivalent to fork() > as the manpage states. Unfortunately, they are right, so I > wrote a new page - see below. > > I consider the introduction of vfork into Linux a very bad move > (as will be clear from the text I wrote), but since there were > people writing code and submitting patches there must be some > positive side to this horrible kludge.
The positive side is that the page tables do not need to be copied, I believe a successful argument was made the page table copy was a significant amount of work. That plus the fact it was about a 10 line kernel patch.
vfork is a special case of clone that causes the parent to block until the child either calls exit or exec.
fork() -> clone(SIGCHLD, sp); vfork() -> clone(CLONE_VFORK | CLONE_VM | SIGCHLD, sp);
A likely more useful variant would call clone with a slightly different stack offset, say a few bytes deeper on the stack.
At any rate vfork in linux is not a bad hack. It is a system call with well defined semantics and strange semantics.
For i386 vfork has it's own kernel entry point. Because someone couldn't figure out how to call clone, and have enough registers left to make vfork work . . .
Eric
- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.rutgers.edu Please read the FAQ at http://www.tux.org/lkml/
| |