Don't use posix_spawn_file_actions_addchdir_np on macOS.

This commit is contained in:
Eric Huss 2020-12-30 14:56:51 -08:00
parent 7d3818152d
commit a938725ef7

View File

@ -314,10 +314,20 @@ impl Command {
) -> libc::c_int
}
let addchdir = match self.get_cwd() {
Some(cwd) => match posix_spawn_file_actions_addchdir_np.get() {
Some(f) => Some((f, cwd)),
None => return Ok(None),
},
Some(cwd) => {
if cfg!(target_os = "macos") {
// 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
// ENOENT when used with posix_spawn_file_actions_addchdir_np
// which was introduced in macOS 10.15.
return Ok(None);
}
match posix_spawn_file_actions_addchdir_np.get() {
Some(f) => Some((f, cwd)),
None => return Ok(None),
}
}
None => None,
};