Skip to content

Commit

Permalink
Terminate after flushing file descriptors
Browse files Browse the repository at this point in the history
  • Loading branch information
john-sharratt committed Nov 5, 2023
1 parent a60676d commit 199db32
Showing 1 changed file with 8 additions and 6 deletions.
14 changes: 8 additions & 6 deletions lib/wasix/src/state/env.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1044,12 +1044,7 @@ impl WasiEnv {
if self.thread.is_main() {
tracing::trace!(pid=%self.pid(), "cleaning up open file handles");

// Now send a signal that the thread is terminated
self.process.signal_process(Signal::Sigquit);

// Terminate the process
let exit_code = exit_code.unwrap_or_else(|| Errno::Canceled.into());
self.process.terminate(exit_code);
let process = self.process.clone();

let timeout = self.tasks().sleep_now(CLEANUP_TIMEOUT);
let state = self.state.clone();
Expand All @@ -1063,6 +1058,13 @@ impl WasiEnv {
},
_ = state.fs.close_all() => { }
}

// Now send a signal that the thread is terminated
process.signal_process(Signal::Sigquit);

// Terminate the process
let exit_code = exit_code.unwrap_or_else(|| Errno::Canceled.into());
process.terminate(exit_code);
})
} else {
Box::pin(async {})
Expand Down

0 comments on commit 199db32

Please sign in to comment.