Expand description
Spawning and talking to child processes.
The API follows std::process, with wait, output and the stdio pipes
made asynchronous.
§How it stays reliable
- Pipes never lose data when an operation is cancelled. One small thread per
pipe copies bytes between the pipe and a bounded in-memory queue;
readtakes from that queue andwriteadds to it. Dropping a pendingread(a timeout, say) leaves the data in the queue for the next one. The queue is capped at 1 MiB per pipe, so a child that writes faster than you read is slowed down by the pipe’s own back-pressure rather than buffered without limit. waitruns on the blocking pool (it pollstry_waitwith a short, growing delay), so waiting on a child never stalls the reactor and works the same on every platform. Dropping a pendingwaitdoes not stop the poll; it ends when the child does.- Children are reaped. Dropping a
Childthat has not been waited for hands it to a background thread that waits for it, so it does not stay a zombie. WithCommand::kill_on_dropit is killed first.
write to a ChildStdin completes when the bytes are accepted into the queue,
not when the child has read them; use ChildStdin::flush or
ChildStdin::shutdown to wait for delivery.
Structs§
- Child
- A running child process.
- Child
Stderr - The child’s standard error.
- Child
Stdin - The child’s standard input.
- Child
Stdout - The child’s standard output.
- Command
- A process builder. See
std::process::Command. - Exit
Status - Describes the result of a process after it has terminated.
- Output
- The output of a finished process.
- Stdio
- Describes what to do with a standard I/O stream for a child process when
passed to the
stdin,stdout, andstderrmethods ofCommand.