src/effect.bend
1# src/effect: the three foreign effects snap runs programs through. Each is
2# written twice, in C for the native lane and in JS for the interpreter, and
3# each reads a wire the planners in src/argv.bend and src/par.bend make.
4import Base
5
6# the program and its arguments, NUL separated (`wire`), run with no shell
7# between. The answer is the exit status on its own first line, then stdout
8# and stderr.
9def snaprun.exec(cmd: String) -> IO(String):
10 import "./exec.c"
11 import "./exec.js"
12
13# a program started and left running, answering with its pid, or 0 when it
14# could not be started. The arguments arrive as `wire` makes them. The effect above
15# waits for what it runs and reads it to the end; this one waits for nothing,
16# and gives the child a session and a /dev/null of its own so it holds no pipe
17# open behind it.
18def snaprun.start(cmd: String) -> IO(String):
19 import "./start.c"
20 import "./start.js"
21
22# several programs run at once, answering with every exit status in the order
23# the jobs were given. The fields arrive as `par.plan` joins them. The children
24# write into a directory rather than down a pipe, and `par` below reads those
25# files back, so this answers statuses alone.
26def snaprun.par(cmd: String) -> IO(String):
27 import "./par.c"
28 import "./par.js"