Skip to content

Commit

Permalink
Fixed the bug in spawn_exec() where non-zero exit codes aren't propag…
Browse files Browse the repository at this point in the history
…ated properly
  • Loading branch information
Michael-F-Bryan committed Oct 27, 2023
1 parent 665fc28 commit b7ca81a
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 10 deletions.
16 changes: 8 additions & 8 deletions lib/wasix/src/bin_factory/exec.rs
Original file line number Diff line number Diff line change
Expand Up @@ -203,13 +203,8 @@ fn call_module(

if let Err(err) = call_ret {
match err.downcast::<WasiError>() {
Ok(WasiError::Exit(code)) => {
if code.is_success() {
Ok(Errno::Success)
} else {
Ok(Errno::Noexec)
}
}
Ok(WasiError::Exit(code)) if code.is_success() => Ok(Errno::Success),
Ok(err @ WasiError::Exit(_)) => Err(err.into()),
Ok(WasiError::DeepSleep(deep)) => {
// Create the callback that will be invoked when the thread respawns after a deep sleep
let rewind = deep.rewind;
Expand All @@ -222,7 +217,12 @@ fn call_module(

// Spawns the WASM process after a trigger
if let Err(err) = unsafe {
tasks.resume_wasm_after_poller(Box::new(respawn), ctx, store, deep.trigger)
tasks.resume_wasm_after_poller(
Box::new(respawn),
ctx,
store,
deep.trigger,
)
} {
debug!("failed to go into deep sleep - {}", err);
}
Expand Down
6 changes: 4 additions & 2 deletions lib/wasix/src/runners/wasi.rs
Original file line number Diff line number Diff line change
Expand Up @@ -244,8 +244,10 @@ impl crate::runners::Runner for WasiRunner {

let exit_code = tasks.spawn_and_block_on(
async move {
let fut = crate::bin_factory::spawn_exec(pkg, &command_name, store, env, &runtime);
let mut task_handle = fut.await.context("Spawn failed")?;
let mut task_handle =
crate::bin_factory::spawn_exec(pkg, &command_name, store, env, &runtime)
.await
.context("Spawn failed")?;

task_handle
.wait_finished()
Expand Down

0 comments on commit b7ca81a

Please sign in to comment.