Skip to content

Commit

Permalink
Make ProcExit call Module.Close()
Browse files Browse the repository at this point in the history
Signed-off-by: Takaya Saeki <[email protected]>
  • Loading branch information
nullpo-head committed Mar 23, 2022
1 parent 59617a2 commit 576d107
Show file tree
Hide file tree
Showing 2 changed files with 201 additions and 80 deletions.
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

0 comments on commit 576d107

Please sign in to comment.