Files
sausage/host/wit/process.wit
T

43 lines
1.3 KiB
Plaintext

package sausage:process@0.1.0;
/// Programs share one world. These resources provide lifecycle and bounded stdio transport.
interface host {
use wasi:io/streams@0.2.12.{input-stream, output-stream};
use wasi:io/poll@0.2.12.{pollable};
enum change-kind { created, modified, removed, overflow }
record change { path: string, kind: change-kind }
resource watcher {
constructor(paths: list<string>);
subscribe: func() -> pollable;
changes: func() -> list<change>;
}
enum stdio { pipe, inherit, null }
record request {
program: string,
argv: list<string>,
env: list<tuple<string, string>>,
cwd: string,
/// None inherits the parent's group. Zero creates a group. A nonzero ID joins a group.
group: option<u32>,
stdin: stdio,
stdout: stdio,
stderr: stdio,
}
resource child {
pid: func() -> u32;
group: func() -> u32;
stdin: func() -> output-stream;
stdout: func() -> input-stream;
stderr: func() -> input-stream;
subscribe: func() -> pollable;
status: func() -> option<s32>;
wait: func() -> s32;
kill: func();
}
spawn: func(request: request) -> result<child, string>;
kill: func(pid: u32) -> result<_, string>;
}
world program {
import host;
}