Skip to content

Commit c15df0b

Browse files
authored
Merge pull request #47 from rust-osdev/fix-error-code
Don't exit with expected exit code when failed to read QEMU exit code
2 parents 736ca1b + 8f42572 commit c15df0b

File tree

1 file changed

+16
-4
lines changed

1 file changed

+16
-4
lines changed

src/subcommand/runner.rs

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -72,10 +72,22 @@ pub(crate) fn runner(args: RunnerArgs) -> Result<i32, ErrorMessage> {
7272
.map_err(|e| format!("Failed to wait for QEMU process: {}", e))?;
7373
return Err(ErrorMessage::from("Timed Out"));
7474
}
75-
Some(exit_status) => match config.test_success_exit_code {
76-
Some(code) if exit_status.code() == Some(code) => 0,
77-
other => other.unwrap_or(1),
78-
},
75+
Some(exit_status) => {
76+
#[cfg(unix)]
77+
{
78+
if exit_status.code().is_none() {
79+
use std::os::unix::process::ExitStatusExt;
80+
if let Some(signal) = exit_status.signal() {
81+
eprintln!("QEMU process was terminated by signal {}", signal);
82+
}
83+
}
84+
}
85+
let qemu_exit_code = exit_status.code().ok_or("Failed to read QEMU exit code")?;
86+
match config.test_success_exit_code {
87+
Some(code) if qemu_exit_code == code => 0,
88+
_ => qemu_exit_code,
89+
}
90+
}
7991
}
8092
} else {
8193
let status = command

0 commit comments

Comments
 (0)