Skip to content

Commit

Permalink
Clean up.
Browse files Browse the repository at this point in the history
  • Loading branch information
lthibault committed Nov 16, 2024
1 parent 1d8193b commit 8b3c483
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 4 deletions.
16 changes: 13 additions & 3 deletions examples/echo/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ import (
"flag"
"io"
"os"

"github.com/wetware/go/std/system"
)

//export echo
Expand All @@ -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.
}
3 changes: 3 additions & 0 deletions std/system/system.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
package system

const StatusAwaiting = 0x00ff0000
3 changes: 2 additions & 1 deletion ww.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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)
}
}
Expand Down

0 comments on commit 8b3c483

Please sign in to comment.