hhvm
hhvm copied to clipboard
Cleanup: Use `posix_spawn()` in `_OS\fork_and_execve()` on MacOS
We currently do a pretty nasty trick to emulate execvpe on MacOS: https://github.com/facebook/hhvm/blob/ceb300a5bf2411b07f7907bd1a613583901b78b7/hphp/util/process.cpp#L644-L657
There's two ways we could clean this up:
- Set the Apple-specific
POSIX_SPAWN_SETEXECflag just to replace the execvp + _NSEnviron stuff call, keep the explicit fork (to share more code with the linux path) - it looks like there's enough extensions now to implement all the fork_and_execve flags directly with
posix_spawn()- we could replace the fork too
We /could/ also take option 2 on modern libcs.
I'm mostly filing this as a reminder. Perhaps we should take the first path now, but I think we should leave the second until there's a new enough libc on all supported linux distributions - we should continue sharing as much code as possible between the linux and macos paths to reduce the chance of platform-specific bugs or varying behavior.