3 ms·
Yes, but they _can_ vfork, and you should be using vfork anyway when all you're going to do after fork is exec.
by quotemstr 12y ago
Yes, but they _can_ vfork, and you should be using vfork anyway when all you're going to do after fork is exec.
- joosters 12y agoGood luck making sure that all your running programs use vfork(). And why would they? If you read the man page, it is hardly encouraging: It is rather unfortunate that Linux revived this specter from the past. The BSD man page states: "This system call will be eliminated when proper system sharing mechanisms are implemented. Users should not depend on the memory sharing semantics of vfork() as it will, in that case, be made synonymous to fork(2)." So no-one has been encouraged to use vfork()
- IgorPartola 12y agoIsn't vfork() 11 years deprecated?
- quotemstr 12y agoDeprecated my ass. It's stable and supported ABI.
- vezzy-fnord 12y agoIt may not be deprecated, but it's a rather unsafe interface: http://ewontfix.com/7/ http://ewontfix.com/7/
- quotemstr 12y agoIt's possible to use safely, and the benefits are worth it --- no commit charge problems and no time spent copying page tables. (Even in the memory itself is copy-on-write, you still have to set up the child's address space.) I'm sick of people cargo-culting ideas like "vfork is bad" without really understanding the issues.
- benmmurphy 12y agosome apps also use fork and the copy on write behaviour deliberately to implement features. redis uses it to create its backup file (http://redis.io/topics/faq http://redis.io/topics/faq) >> Redis background saving schema relies on the copy-on-write semantic of fork in modern operating systems: Redis forks (creates a child process) that is an exact copy of the parent. The child process dumps the DB on disk and finally exits.