Support posix_spawn() for Linux glibc 2.24+.
The relevant support was added in https://sourceware.org/bugzilla/show_bug.cgi?id=10354#c12
This commit is contained in:
@@ -235,7 +235,8 @@ impl Command {
|
||||
io::Error::last_os_error()
|
||||
}
|
||||
|
||||
#[cfg(not(any(target_os = "macos", target_os = "freebsd")))]
|
||||
#[cfg(not(any(target_os = "macos", target_os = "freebsd",
|
||||
all(target_os = "linux", target_env = "gnu"))))]
|
||||
fn posix_spawn(&mut self, _: &ChildPipes, _: Option<&CStringArray>)
|
||||
-> io::Result<Option<Process>>
|
||||
{
|
||||
@@ -244,7 +245,8 @@ impl Command {
|
||||
|
||||
// Only support platforms for which posix_spawn() can return ENOENT
|
||||
// directly.
|
||||
#[cfg(any(target_os = "macos", target_os = "freebsd"))]
|
||||
#[cfg(any(target_os = "macos", target_os = "freebsd",
|
||||
all(target_os = "linux", target_env = "gnu")))]
|
||||
fn posix_spawn(&mut self, stdio: &ChildPipes, envp: Option<&CStringArray>)
|
||||
-> io::Result<Option<Process>>
|
||||
{
|
||||
@@ -258,6 +260,18 @@ impl Command {
|
||||
return Ok(None)
|
||||
}
|
||||
|
||||
// Only glibc 2.24+ posix_spawn() supports returning ENOENT directly.
|
||||
#[cfg(all(target_os = "linux", target_env = "gnu"))]
|
||||
{
|
||||
if let Some(version) = sys::os::glibc_version() {
|
||||
if version < (2, 24) {
|
||||
return Ok(None)
|
||||
}
|
||||
} else {
|
||||
return Ok(None)
|
||||
}
|
||||
}
|
||||
|
||||
let mut p = Process { pid: 0, status: None };
|
||||
|
||||
struct PosixSpawnFileActions(libc::posix_spawn_file_actions_t);
|
||||
|
||||
Reference in New Issue
Block a user