Support posix_spawn() for FreeBSD.

spawn() is expected to return an error if the specified file could not be
executed.  FreeBSD's posix_spawn() supports returning ENOENT/ENOEXEC if
the exec() fails, which not all platforms support.  This brings a very
significant performance improvement for FreeBSD, involving heavy use of
Command in threads, due to fork() invoking jemalloc fork handlers and
causing lock contention.  FreeBSD's posix_spawn() avoids this problem
due to using vfork() internally.
This commit is contained in:
Bryan Drewery
2018-02-27 14:12:52 -08:00
parent b3ecf5f57c
commit 85b82f254e

View File

@@ -235,14 +235,14 @@ impl Command {
io::Error::last_os_error()
}
#[cfg(not(any(target_os = "linux", target_os = "macos")))]
#[cfg(not(any(target_os = "freebsd")))]
fn posix_spawn(&mut self, _stdio: &ChildPipes, _envp: Option<&CStringArray>)
-> io::Result<Option<Process>>
{
Ok(None)
}
#[cfg(any(target_os = "linux", target_os = "macos"))]
#[cfg(any(target_os = "freebsd"))]
fn posix_spawn(&mut self, stdio: &ChildPipes, envp: Option<&CStringArray>)
-> io::Result<Option<Process>>
{