create ~prog ~args ()
uses fork
and exec
to create a child process that runs the executable prog
with args
as arguments. It creates pipes to communicate with the child process's stdin
, stdout
, and stderr
.
Unlike exec
, args
should not include prog
as the first argument.
If buf_len
is supplied, it determines the size of the reader and writer buffers used to communicate with the child process's stdin
, stdout
, and stderr
.
If stdin
is supplied, then the writer to the child's stdin will have ~raise_when_consumer_leaves:false
and ~buffer_age_limit:`Unlimited
, which makes it more robust.
env
specifies the environment of the child process.
If working_dir
is supplied, then the child process will chdir()
there before calling exec()
.
create
returns Error
if it is unable to create the child process. This can happen in any number of situations (unable to fork, unable to create the pipes, unable to cd to working_dir
, etc.). create
does not return error
if exec
fails; instead, it returns OK t
, where wait t
returns an Error
.