Running other programs
WASI can’t start processes, so wackasm_opencomputers::process provides an
API in the style of std::process:
Command
Section titled “Command”arg,args: arguments;env,envs,env_remove,env_clear: the environment, which children otherwise inherit;current_dir: where the child starts (default: this program’s current directory);disk: load the program from this filesystem only;Command::from_image(name, bytes): run a wasm binary held in memory.
Then status(), output() or spawn().
A name is looked up in each directory of PATH (default /bin), as
NAME.wasm and then NAME. Disks are searched in order: this program’s
own, then the boot disk, then the rest. A name containing / is a path,
relative to the child’s directory. A missing program is
Error::ProgramNotFound.
next_event()runs the child until it does something:Event::Output(bytes),Event::Input(it wants stdin), orEvent::Exit(status);write_stdin,close_stdin: answerInput;wait(): relay the child’s output and input through this program’s own stdio until it exits. This works at any depth, which is howtime lines cat x.txtreaches the screen;wait_with_output(): collect output until it exits;kill(). Dropping a runningChildkills it.
ExitStatus is Exited(code) or Crashed(message).
Limits
Section titled “Limits”- One child per process at a time. A pipeline has to run one stage after another, buffering output between them.
- stderr is merged into stdout.
- All processes share the computer’s RAM.