about summary refs log tree commit diff
path: root/src/libstd/sys/unix
diff options
context:
space:
mode:
authorBryan Drewery <bryan@shatow.net>2018-03-02 13:02:38 -0800
committerBryan Drewery <bryan@shatow.net>2018-03-02 13:08:04 -0800
commitd740083fc8981ee933dc48a6b3dcee21b82c993e (patch)
tree199ec7bb1d8b40705e5be2a5cb001850312b4636 /src/libstd/sys/unix
parent5ba6b3a728fb50cd65237b8eeac2f2df05c3c77f (diff)
downloadrust-d740083fc8981ee933dc48a6b3dcee21b82c993e.tar.gz
rust-d740083fc8981ee933dc48a6b3dcee21b82c993e.zip
Support posix_spawn() for Linux glibc 2.24+.
The relevant support was added in https://sourceware.org/bugzilla/show_bug.cgi?id=10354#c12
Diffstat (limited to 'src/libstd/sys/unix')
-rw-r--r--src/libstd/sys/unix/process/process_unix.rs18
1 files changed, 16 insertions, 2 deletions
diff --git a/src/libstd/sys/unix/process/process_unix.rs b/src/libstd/sys/unix/process/process_unix.rs
index 51ae0aa7315..29e33ee822e 100644
--- a/src/libstd/sys/unix/process/process_unix.rs
+++ b/src/libstd/sys/unix/process/process_unix.rs
@@ -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);