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) } }