# Subprocesses and child processes

> One recording holds every Python process that the command started, each linked to the process that started it, and says which Python processes it missed.

`ormaos run` records every Python process the command creates, not only the first one: Python subprocesses and `multiprocessing` children are in the same recording, each linked to the process that started it.

## How a child is recorded

The recorder starts in a child process through the `ormaos.pth` file that the package installs, driven by environment variables (`ORMAOS_DIR`, `ORMAOS_PATH`, `ORMAOS_IO`). A child is recorded when:

- it runs a Python in which `ormaos` is installed,
- with its site packages (not `-S`),
- and with `ORMAOS_DIR` in its environment.

`ormaos status` says whether the recorder starts by itself here (`starts by itself under run: yes`).

## What the recording says about them

- `ormaos show --full` lists every process: its pid, its parent, the Python and its path, what it recorded, its counts and how it ended.
- A process that a signal ended is named with the signal and who sent it: its pool, the program (`terminate()`, `kill()`, `os.kill`), or a signal the program was not seen sending.
- When the program started a Python with `subprocess` and that Python was not recorded, the recording says how many are missing. That count comes from the I/O events, so with `--no-io` it is not made, and `not_collected` says so. When no Python at all was recorded, it says that.

## Which process an event is in

Every call, exception, I/O event and logging record says which process it ran in, as a small number of the recording (`process 1`, `process 2`). `ormaos run` waits up to one second at the end for Python processes of the recording that are still alive, so that the summary does not call the recording incomplete because of them.

## Subprocesses as I/O

A program started with `subprocess` or `os.exec*`/`os.posix_spawn` is also an I/O event of kind `subprocess`: its name and how many arguments, never the arguments, environment or output. `os.system` is recorded as `system shell` and `os.fork` as `fork`.

> **Limit.**
> Web servers that start worker processes (uvicorn, gunicorn) are not in the compatibility matrix of ormaos-python yet. See [Not yet](/not-yet.md).

---

Source: https://docs.ormaos.com/python/concepts/subprocesses/ · ormaos 0.0.1 · ormaos-python 968f69776c · ormaos-examples 6e27be5922
