os/spawn
core-api
cfunction
src/core/os.c on line 1402, column 1
(os/spawn args &opt flags env)
Execute a program on the system and return a core/process value
representing the spawned subprocess. Takes the same arguments as
`os/execute` but does not wait for the subprocess to complete.
Unlike `os/execute`, the value `:pipe` can be used for :in, :out
and :err keys in `env`. If used, the returned core/process will
have a writable stream in the :in field and readable streams in the
:out and :err fields. On non-Windows systems, the subprocess PID
will be in the :pid field. The caller is responsible for waiting on
the process (e.g. by calling `os/proc-wait` on the returned
core/process value) to avoid creating zombie process. After the
subprocess completes, the exit value is in the :return-code field.
If `flags` includes 'x', a non-zero exit code will cause a waiting
fiber to raise an error. The use of `:pipe` may fail if there are
too many active file descriptors. The caller is responsible for
closing pipes created by `:pipe` (either individually or using
`os/proc-close`). Similar to `os/execute`, the caller is
responsible for ensuring pipes do not cause the program to block
and deadlock.