Skip to content

Commit

Permalink
Truncate exit code to u8, even if the real code doesn't fit in u8.
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
jakobnissen committed Oct 26, 2023
1 parent 6801789 commit a0d0817
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/bin/julialauncher.rs
Original file line number Diff line number Diff line change
Expand Up @@ -366,7 +366,8 @@ fn main() -> Result<std::process::ExitCode> {
}
}

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))
}

0 comments on commit a0d0817

Please sign in to comment.