Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Terminate after flushing file descriptors #4294

Merged
merged 1 commit into from
Nov 6, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading