From 8b3c4838facc9e9a334afbe670b7fb7ee0f666fb Mon Sep 17 00:00:00 2001 From: Louis Thibault Date: Fri, 15 Nov 2024 19:00:50 -0500 Subject: [PATCH] Clean up. --- examples/echo/main.go | 16 +++++++++++++--- std/system/system.go | 3 +++ ww.go | 3 ++- 3 files changed, 18 insertions(+), 4 deletions(-) create mode 100644 std/system/system.go diff --git a/examples/echo/main.go b/examples/echo/main.go index 452460d..d61d429 100644 --- a/examples/echo/main.go +++ b/examples/echo/main.go @@ -6,6 +6,8 @@ import ( "flag" "io" "os" + + "github.com/wetware/go/std/system" ) //export echo @@ -25,8 +27,16 @@ func main() { } if *serve { - // Signal to caller that this module is ready to handle - // incoming method calls. - os.Exit(0x00ff0000) + // Yield control to the scheduler. + os.Exit(system.StatusAwaiting) + // The caller will intercept interface{ExitCode() uint32} and + // check if e.ExitCode() == system.StatusAwaiting. + // + // The top-level command will block until the runtime context + // expires. } + + // Implicit status code 0 works as expected. + // Caller will resolve to err = nil. + // Top-level CLI command will unblock. } diff --git a/std/system/system.go b/std/system/system.go new file mode 100644 index 0000000..2b60aee --- /dev/null +++ b/std/system/system.go @@ -0,0 +1,3 @@ +package system + +const StatusAwaiting = 0x00ff0000 diff --git a/ww.go b/ww.go index 5beeeef..ef8ad6c 100644 --- a/ww.go +++ b/ww.go @@ -8,6 +8,7 @@ import ( "github.com/blang/semver/v4" "github.com/tetratelabs/wazero" "github.com/wetware/go/proc" + guest "github.com/wetware/go/std/system" "github.com/wetware/go/system" protoutils "github.com/wetware/go/util/proto" @@ -68,7 +69,7 @@ func (env Env) Bind(ctx context.Context, r wazero.Runtime) error { switch e.ExitCode() { case 0: return nil - case ExitCodePivot: + case guest.StatusAwaiting: return env.Net.ServeProc(ctx, p) } }