Skip to main content

Module process

Module process 

Source
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; read takes from that queue and write adds to it. Dropping a pending read (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.
  • wait runs on the blocking pool (it polls try_wait with a short, growing delay), so waiting on a child never stalls the reactor and works the same on every platform. Dropping a pending wait does not stop the poll; it ends when the child does.
  • Children are reaped. Dropping a Child that has not been waited for hands it to a background thread that waits for it, so it does not stay a zombie. With Command::kill_on_drop it 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.
ChildStderr
The child’s standard error.
ChildStdin
The child’s standard input.
ChildStdout
The child’s standard output.
Command
A process builder. See std::process::Command.
ExitStatus
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, and stderr methods of Command.