Skip to content

Child process

Category: Units of execution · Status: stub · Lessons: chapter 08, Processes (planned)

One line: A process started by another program, which can pass it input, read its output, wait for it and learn how it ended.

Also called: subprocess, spawn, fork and exec.

How it connects

flowchart LR
  n_subprocess["Child process"]
  n_process["Process"]
  n_subprocess -->|is a| n_process
  classDef center stroke-width:3px
  class n_subprocess center
  classDef outside stroke-dasharray: 4 3
  class n_process outside

In each language

Rust std::process::Command
Go os/exec
C posix_spawn, or fork then exec, and waitpid for the exit status
Java ProcessBuilder
Python subprocess, and asyncio subprocesses ↗ for use inside an event loop
JavaScript Node's child_process

Where to read more