about summary refs log tree commit diff
diff options
context:
space:
mode:
authorMads Marquart <mads@marquart.dk>2024-04-28 22:34:51 +0200
committerMads Marquart <mads@marquart.dk>2024-04-28 22:34:51 +0200
commitf9f3573b62107983c22b27dae40d275930f31d4c (patch)
tree4683d0be788721536d82c530c2dc855ff844032f
parent6b488cd3021a7438cb58c11af822e206b05d038d (diff)
downloadrust-f9f3573b62107983c22b27dae40d275930f31d4c.tar.gz
rust-f9f3573b62107983c22b27dae40d275930f31d4c.zip
Fix posix_spawn not being used on iOS and visionOS
`man posix_spawn` documents it to be able to return `ENOENT`, and there
should be nothing preventing this. Tested in the iOS simulator and on
Mac Catalyst.
-rw-r--r--library/std/src/sys/pal/unix/process/process_unix.rs11
1 files changed, 3 insertions, 8 deletions
diff --git a/library/std/src/sys/pal/unix/process/process_unix.rs b/library/std/src/sys/pal/unix/process/process_unix.rs
index 0ce09c90bbd..f2947161cd5 100644
--- a/library/std/src/sys/pal/unix/process/process_unix.rs
+++ b/library/std/src/sys/pal/unix/process/process_unix.rs
@@ -420,13 +420,11 @@ impl Command {
     }
 
     #[cfg(not(any(
-        target_os = "macos",
-        target_os = "tvos",
-        target_os = "watchos",
         target_os = "freebsd",
         all(target_os = "linux", target_env = "gnu"),
         all(target_os = "linux", target_env = "musl"),
         target_os = "nto",
+        target_vendor = "apple",
     )))]
     fn posix_spawn(
         &mut self,
@@ -439,14 +437,11 @@ impl Command {
     // Only support platforms for which posix_spawn() can return ENOENT
     // directly.
     #[cfg(any(
-        target_os = "macos",
-        // FIXME: `target_os = "ios"`?
-        target_os = "tvos",
-        target_os = "watchos",
         target_os = "freebsd",
         all(target_os = "linux", target_env = "gnu"),
         all(target_os = "linux", target_env = "musl"),
         target_os = "nto",
+        target_vendor = "apple",
     ))]
     fn posix_spawn(
         &mut self,
@@ -530,7 +525,7 @@ impl Command {
         }
         let addchdir = match self.get_cwd() {
             Some(cwd) => {
-                if cfg!(any(target_os = "macos", target_os = "tvos", target_os = "watchos")) {
+                if cfg!(target_vendor = "apple") {
                     // There is a bug in macOS where a relative executable
                     // path like "../myprogram" will cause `posix_spawn` to
                     // successfully launch the program, but erroneously return