Skip to content

Commit a938725

Browse files
committed
Don't use posix_spawn_file_actions_addchdir_np on macOS.
1 parent 7d38181 commit a938725

File tree

1 file changed

+14
-4
lines changed

1 file changed

+14
-4
lines changed

Diff for: library/std/src/sys/unix/process/process_unix.rs

+14-4
Original file line numberDiff line numberDiff line change
@@ -314,10 +314,20 @@ impl Command {
314314
) -> libc::c_int
315315
}
316316
let addchdir = match self.get_cwd() {
317-
Some(cwd) => match posix_spawn_file_actions_addchdir_np.get() {
318-
Some(f) => Some((f, cwd)),
319-
None => return Ok(None),
320-
},
317+
Some(cwd) => {
318+
if cfg!(target_os = "macos") {
319+
// There is a bug in macOS where a relative executable
320+
// path like "../myprogram" will cause `posix_spawn` to
321+
// successfully launch the program, but erroneously return
322+
// ENOENT when used with posix_spawn_file_actions_addchdir_np
323+
// which was introduced in macOS 10.15.
324+
return Ok(None);
325+
}
326+
match posix_spawn_file_actions_addchdir_np.get() {
327+
Some(f) => Some((f, cwd)),
328+
None => return Ok(None),
329+
}
330+
}
321331
None => None,
322332
};
323333

0 commit comments

Comments
 (0)