This module contains various types and functions to allow you to spawn and interact with child processes.
It is intended to be imported qualified, as follows:
import Node.ChildProcess (ChildProcess, CHILD_PROCESS) import Node.ChildProcess as ChildProcess
The Node.js documentation forms the basis for this module and has in-depth documentation about runtime behaviour.
Opaque type returned by
Needed as input for most methods in this module.
kill :: Signal -> ChildProcess -> Effect Unit
Send a signal to a child process. In the same way as the unix kill(2) system call, sending a signal to a child process won't necessarily kill it.
The resulting effects of this function depend on the process
and the signal. They can vary from system to system.
The child process might emit an
"error" event if the signal
could not be delivered.
spawn :: String -> Array String -> SpawnOptions -> Effect ChildProcess
Spawn a child process. Note that, in the event that a child process could
not be spawned (for example, if the executable was not found) this will
not throw an error. Instead, the
ChildProcess will be created anyway,
but it will immediately emit an 'error' event.
exec :: String -> ExecOptions -> (ExecResult -> Effect Unit) -> Effect ChildProcess
spawn, except that this variant will:
- run the given command with the shell,
- buffer output, and wait until the process has exited before calling the callback.
Note that the child process will be killed if the amount of output exceeds a certain threshold (the default is defined by Node.js).
Behaviour for standard IO streams (eg, standard input, standard output) of a child process.
Pipe: creates a pipe between the child and parent process, which can then be accessed as a
Ignore: ignore this stream. This will cause Node to open /dev/null and connect it to the stream.
ShareStream: Connect the supplied stream to the corresponding file descriptor in the child.
ShareFD: Connect the supplied file descriptor (which should be open in the parent) to the corresponding file descriptor in the child.