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

Make ProcExit call Module.Close() #405

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
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
5 changes: 4 additions & 1 deletion internal/wasi/wasi.go
Original file line number Diff line number Diff line change
Expand Up @@ -1452,7 +1452,10 @@ func (a *wasiAPI) PollOneoff(ctx wasm.Module, in, out, nsubscriptions, resultNev
}

// ProcExit implements SnapshotPreview1.ProcExit
func (a *wasiAPI) ProcExit(exitCode uint32) {
func (a *wasiAPI) ProcExit(ctx wasm.Module, exitCode uint32) {
// ProcExit makes the caller module no longer usable, so we can close the module and can release the resources.
// See https://github.com/WebAssembly/WASI/issues/26#issuecomment-1051176870
ctx.Close()
// Panic in a host function is caught by the engines, and the value of the panic is returned as the error of the CallFunction.
// See the document of SnapshotPreview1.ProcExit.
panic(wasi.ExitCode(exitCode))
Expand Down
Loading