Expand description
Child processes started in a session of their own, such as shell
commands, so they never read the terminal and are killed as a group, and
the Launcher that says how every tool starts them. A Process it
spawns takes its input, hands its output over line
by line, and is stopped gently or killed with its whole group.
Structs§
- Group
- A
Process’s group, to stop from another thread. It acts only while the process runs: once it was reaped, its id may name another process. - Kill
OnDrop - Stops a
Process’s group when dropped: kept in a future that waits for the process on another thread (blocking), it asks the group to stop (SIGTERM) the moment the future is dropped, such as when a call is interrupted or the app quits, and kills itSTOP_GRACElater if it still runs. The thread waiting for the process must go on reaping it meanwhile, asProcess::rundoes. - Launcher
- How tools start processes: under a wrapper program (a sandbox such as
bwrap … --,nice -n 10, a container’sexec), in a directory, with variables set and removed. Every command it builds isdetached. A host that hands one launcher to every tool that starts processes (Shell, a background job, a formatter) puts them all under the same policy. - Process
- A process
Launcher::spawnstarted, the leader of a process group of its own. Dropping it while it runs kills the group and reaps it. - Spawn
- How
Launcher::spawnconnects a process.
Enums§
- Ended
- How
Process::run’s wait ended. - Output
Line - A piece of a process’s output, as
Process::lineshands it over: a line with its\n, or the end of the output without one. A line longer than 64 KB comes in pieces. Bytes that are not UTF-8 are replaced.
Constants§
- STOP_
GRACE - How long a process asked to stop (
SIGTERM) has to end before it is killed: time for a transport that hangs up the command it runs on another machine when it is stopped to do so.
Functions§
- detach
- Starts
commandin a new session, which also makes it the leader of a new process group. With no controlling terminal, a program that opens/dev/ttyfor a prompt (ssh, git, sudo) fails at once instead of drawing over the view and stopping on a terminal read. Git is also told not to prompt. - kill_
group - Kills the process group
childleads, created bydetach; elsewhere, the child alone. - kill_
group_ of - Kills the process group led by the process
leader. Its id names that group while the leader is not reaped or any member lives: the kernel does not reuse the id of a process group that exists. Once the leader was reaped and the group emptied, the id is free again, so callers kill within moments of the reap.