syscall: use posix_spawn (or vfork) for ForkExec when possible · Issue #5838 · golang/go (original) (raw)
Navigation Menu
- Explore
- Pricing
Provide feedback
Saved searches
Use saved searches to filter your results more quickly
Appearance settings
Description
Why:
At a basic level posix_spawn(2) is a subset of fork(2). A new child process from fork(2): 1) gets an exact copy of everything that the parent process had in memory, and 2) gets a copy of all the file descriptors that the parent process had open. posix_spawn(2) preserves #2, but not #1. In some cases, say, shelling out a command, it's unnecessary to get a copy of memory of the parent process. With copy-on-write, fork will be less expensive but still, not necessary.
What's out there:
https://github.com/rtomayko/posix-spawn#benchmarks
I am wondering if it makes sense to have this API and let developers decide which one to use (fork/exec vs. posix_spawn)