Skip to main content

Spawns new subprocess. RunOptions must contain at a minimum the opt.cmd, an array of program arguments, the first of which is the binary.

const p ={
  cmd: ["echo", "hello"],

Subprocess uses same working directory as parent process unless opt.cwd is specified.

Environmental variables for subprocess can be specified using opt.env mapping.

By default subprocess inherits stdio of parent process. To change that opt.stdout, opt.stderr and opt.stdin can be specified independently - they can be set to either an rid of open file or set to "inherit" "piped" or "null":

"inherit" The default if unspecified. The child inherits from the corresponding parent descriptor.

"piped" A new pipe should be arranged to connect the parent and child sub-processes.

"null" This stream will be ignored. This is the equivalent of attaching the stream to /dev/null.

Details of the spawned process are returned.

Requires allow-run permission.