Skip to content

Commit

Permalink
Remove exit code restriction on Windows
Browse files Browse the repository at this point in the history
  • Loading branch information
badeend committed Oct 6, 2024
1 parent 4dbca40 commit 2f48c77
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 19 deletions.
14 changes: 0 additions & 14 deletions crates/wasi/src/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,20 +9,6 @@ use std::marker;
#[derive(Debug)]
pub struct I32Exit(pub i32);

impl I32Exit {
/// Accessor for an exit code appropriate for calling `std::process::exit` with,
/// when interpreting this `I32Exit` as an exit for the parent process.
///
/// This method masks off exit codes which are illegal on Windows.
pub fn process_exit_code(&self) -> i32 {
if cfg!(windows) && self.0 >= 3 {
1
} else {
self.0
}
}
}

impl fmt::Display for I32Exit {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
write!(f, "Exited with i32 exit status {}", self.0)
Expand Down
7 changes: 2 additions & 5 deletions src/commands/run.rs
Original file line number Diff line number Diff line change
Expand Up @@ -230,11 +230,8 @@ impl RunCommand {
if store.data().preview1_ctx.is_some() {
return Err(wasi_common::maybe_exit_on_error(e));
} else if store.data().preview2_ctx.is_some() {
if let Some(exit) = e
.downcast_ref::<wasmtime_wasi::I32Exit>()
.map(|c| c.process_exit_code())
{
std::process::exit(exit);
if let Some(exit) = e.downcast_ref::<wasmtime_wasi::I32Exit>() {
std::process::exit(exit.0);
}
if e.is::<wasmtime::Trap>() {
eprintln!("Error: {e:?}");
Expand Down

0 comments on commit 2f48c77

Please sign in to comment.