Skip to content

Commit 4a2abd3

Browse files
committed
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.
1 parent ae52df6 commit 4a2abd3

File tree

1 file changed

+3
-8
lines changed

1 file changed

+3
-8
lines changed

std/src/sys/pal/unix/process/process_unix.rs

+3-8
Original file line numberDiff line numberDiff line change
@@ -420,13 +420,11 @@ impl Command {
420420
}
421421

422422
#[cfg(not(any(
423-
target_os = "macos",
424-
target_os = "tvos",
425-
target_os = "watchos",
426423
target_os = "freebsd",
427424
all(target_os = "linux", target_env = "gnu"),
428425
all(target_os = "linux", target_env = "musl"),
429426
target_os = "nto",
427+
target_vendor = "apple",
430428
)))]
431429
fn posix_spawn(
432430
&mut self,
@@ -439,14 +437,11 @@ impl Command {
439437
// Only support platforms for which posix_spawn() can return ENOENT
440438
// directly.
441439
#[cfg(any(
442-
target_os = "macos",
443-
// FIXME: `target_os = "ios"`?
444-
target_os = "tvos",
445-
target_os = "watchos",
446440
target_os = "freebsd",
447441
all(target_os = "linux", target_env = "gnu"),
448442
all(target_os = "linux", target_env = "musl"),
449443
target_os = "nto",
444+
target_vendor = "apple",
450445
))]
451446
fn posix_spawn(
452447
&mut self,
@@ -530,7 +525,7 @@ impl Command {
530525
}
531526
let addchdir = match self.get_cwd() {
532527
Some(cwd) => {
533-
if cfg!(any(target_os = "macos", target_os = "tvos", target_os = "watchos")) {
528+
if cfg!(target_vendor = "apple") {
534529
// There is a bug in macOS where a relative executable
535530
// path like "../myprogram" will cause `posix_spawn` to
536531
// successfully launch the program, but erroneously return

0 commit comments

Comments
 (0)