Skip to content

Commit

Permalink
Pass process mailbox to stdin.
Browse files Browse the repository at this point in the history
  • Loading branch information
lthibault committed Dec 18, 2024
1 parent b17b75d commit 6e31ee8
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions proc/proc.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,12 @@ type Command struct {
}

func (cmd Command) Instantiate(ctx context.Context, r wazero.Runtime, cm wazero.CompiledModule) (*P, error) {
mod, err := r.InstantiateModule(ctx, cm, cmd.WithEnv(wazero.NewModuleConfig().
var p P
var err error
p.Mod, err = r.InstantiateModule(ctx, cm, cmd.WithEnv(wazero.NewModuleConfig().
WithName(cmd.PID.String()).
WithArgs(cmd.Args...).
WithStdin(&p.Mailbox).
WithStdout(cmd.Stdout).
WithStderr(cmd.Stderr).
WithEnv("WW_PID", cmd.PID.String()).
Expand All @@ -45,7 +48,7 @@ func (cmd Command) Instantiate(ctx context.Context, r wazero.Runtime, cm wazero.
WithSysNanotime().
WithSysWalltime().
WithStartFunctions()))
return &P{Mod: mod}, err
return &p, err
}

func (cfg Command) WithEnv(mc wazero.ModuleConfig) wazero.ModuleConfig {
Expand Down

0 comments on commit 6e31ee8

Please sign in to comment.