Skip to main content
function Child.interrupt
def Child.interrupt() -> None
Send the child an interrupt now, what Ctrl+C at a terminal delivers (SIGINT; a console break on Windows), to its whole process group when it leads one. One signal, no escalation; wait() to see the result. function Child.kill
def Child.kill() -> None
Forces the child process to exit (SIGKILL), and with it every process in its process group when it leads one. If the child has already exited, it is a no-op. function Child.stderr
def Child.stderr() -> std.io.Readable
The handle for reading from the child’s standard error (stderr), if it has been captured. Calling this function more than once will yield error. function Child.stdin
def Child.stdin() -> std.io.Writable
The handle for writing to the child’s standard input (stdin), if it has been captured. Calling this function more than once will yield error. function Child.stdout
def Child.stdout() -> std.io.Readable
The handle for reading from the child’s standard output (stdout), if it has been captured. Calling this function more than once will yield error. function Child.terminate
def Child.terminate() -> None
Ask the child to exit now (SIGTERM; a console break on Windows), to its whole process group when it leads one. One signal, no escalation; wait() to see the result. function Child.try_wait
def Child.try_wait(
*,
timeout_ms: int = 0
) -> typing.Any
Check for child exit. Returns None if the child is still running, or ExitStatus if it has exited. Does not consume the child — stdout/stderr stream accessors remain callable after this returns a status, allowing pipe contents to be drained via child.stdout().readototstring() etc. Non-blocking by default; with timeout_ms it waits up to that long for the child to exit before returning None, a bounded wait for a loop that also watches a cancellation token. function Child.wait
def Child.wait() -> std.process.ExitStatus
Waits for the child to exit completely, returning the status that it exited with. This function will continue to have the same return value after it has been called at least once. The stdin handle to the child process, if any, will be closed before waiting. This helps avoid deadlock: it ensures that the child does not block waiting for input from the parent, while the parent waits for the child to exit. The wait ends the task instead if ctx.cancellation.root is cancelled meanwhile and no intercept() is in effect; the child is already stopping by then. function Child.wait_with_output
def Child.wait_with_output() -> std.process.Output
WARNING: Calling wait_with_output consumes the child instance, causing errors on subsequent calls to other methods. Simultaneously waits for the child to exit and collect all remaining output on the stdout/stderr handles, returning an Output instance. The stdin handle to the child process, if any, will be closed before waiting. This helps avoid deadlock: it ensures that the child does not block waiting for input from the parent, while the parent waits for the child to exit. By default, stdin, stdout and stderr are inherited from the parent. In order to capture the output into this Result<Output> it is necessary to create new pipes between parent and child. Use stdout('piped') or stderr('piped'), respectively. property Child.cancellation
Child.cancellation: cancellation.Token
The child’s cancellation token, a child() of the one passed as cancellation = at the spawn (ctx.cancellation.root by default). child.cancellation.cancel() stops this one child the way cancellation does: a terminate signal (to its whole process group when it leads one), then a kill three seconds later if needed. property Child.id
Child.id: int
Returns the OS-assigned process identifier associated with this child.