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
- Is a kind of: Process
- See also: Inter-process communication
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¶
- In this library: Who waits when main returns?
- In the books: Python Concurrency with asyncio, Matthew Fowler — ch. 13, 'Managing subprocesses'
- In the books: Python Asyncio Jump-Start, Jason Brownlee — ch. 6, 'Subprocesses and Streams'
- In the books: JavaScript Concurrency, Adam Boduch — ch. 9, 'Advanced NodeJS Concurrency' → 'Child Processes'
- In the books: Effective Python, Brett Slatkin — ch. 7, 'Concurrency and Parallelism' → 'Item 52: Use subprocess to Manage Child Processes'
- In the books: Python in a Nutshell, Alex Martelli, Anna Ravenscroft, Steve Holden — ch. 14, 'Threads and Processes' → 'Running Other Programs'
- Reference: Wikipedia: Child process ↗