From a0d08177d0201291917368394a108592cea2cf86 Mon Sep 17 00:00:00 2001 From: Jakob Nybo Nissen Date: Thu, 26 Oct 2023 13:32:27 +0200 Subject: [PATCH] Truncate exit code to u8, even if the real code doesn't fit in u8. This prevents JuliaLauncher from panicking if a user exits with an error code which doesn't fit in u8. This is already the behaviour of Julia on Linux, where `ccall(:jl_exit)` can be called with Int32(-1), yet returns error code 255. --- src/bin/julialauncher.rs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/bin/julialauncher.rs b/src/bin/julialauncher.rs index 388da0f9..f008506e 100644 --- a/src/bin/julialauncher.rs +++ b/src/bin/julialauncher.rs @@ -366,7 +366,8 @@ fn main() -> Result { } } - let client_status: u8 = client_status?.try_into().unwrap(); + // We truncate to the lower 8 bytes, even though a Windows exit code is i32 + let client_status: u8 = client_status? as u8; Ok(std::process::ExitCode::from(client_status)) }