From 2f48c77867d0bd02c4c910510f491a71da22a0f0 Mon Sep 17 00:00:00 2001 From: badeend Date: Sun, 6 Oct 2024 11:15:08 +0200 Subject: [PATCH] Remove exit code restriction on Windows --- crates/wasi/src/error.rs | 14 -------------- src/commands/run.rs | 7 ++----- 2 files changed, 2 insertions(+), 19 deletions(-) diff --git a/crates/wasi/src/error.rs b/crates/wasi/src/error.rs index a019b4a7a2e7..f92317c1fef7 100644 --- a/crates/wasi/src/error.rs +++ b/crates/wasi/src/error.rs @@ -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) diff --git a/src/commands/run.rs b/src/commands/run.rs index d8a7cc90ae52..ee0ba69bf902 100644 --- a/src/commands/run.rs +++ b/src/commands/run.rs @@ -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::() - .map(|c| c.process_exit_code()) - { - std::process::exit(exit); + if let Some(exit) = e.downcast_ref::() { + std::process::exit(exit.0); } if e.is::() { eprintln!("Error: {e:?}");