Skip to content

Commit 6e1257d

Browse files
committed
Use real exec on cfg(unix) targets
1 parent 302e9ae commit 6e1257d

File tree

1 file changed

+16
-3
lines changed

1 file changed

+16
-3
lines changed

cargo-miri/bin.rs

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -239,9 +239,22 @@ fn xargo_check() -> Command {
239239
/// Execute the command. If it fails, fail this process with the same exit code.
240240
/// Otherwise, continue.
241241
fn exec(mut cmd: Command) {
242-
let exit_status = cmd.status().expect("failed to run command");
243-
if exit_status.success().not() {
244-
std::process::exit(exit_status.code().unwrap_or(-1))
242+
// On non-Unix imitate POSIX exec as closely as we can
243+
#[cfg(not(unix))]
244+
{
245+
let exit_status = cmd.status().expect("failed to run command");
246+
if exit_status.success().not() {
247+
std::process::exit(exit_status.code().unwrap_or(-1))
248+
}
249+
}
250+
// On Unix targets, actually exec
251+
// If exec returns, process setup has failed. This is the same error condition as the expect in
252+
// the non-Unix case.
253+
#[cfg(unix)]
254+
{
255+
use std::os::unix::process::CommandExt;
256+
let error = cmd.exec();
257+
Err(error).expect("failed to run command")
245258
}
246259
}
247260

0 commit comments

Comments
 (0)