Skip to content

Commit

Permalink
Fix posix_spawn not being used on iOS and visionOS
Browse files Browse the repository at this point in the history
`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.
  • Loading branch information
madsmtm committed Apr 28, 2024
1 parent 6b488cd commit f9f3573
Showing 1 changed file with 3 additions and 8 deletions.
11 changes: 3 additions & 8 deletions library/std/src/sys/pal/unix/process/process_unix.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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,
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit f9f3573

Please sign in to comment.