Documentation
¶
Overview ¶
Package proctree runs external tools that start processes of their own, and makes sure none of them outlives the reason it was started.
An indexer is not one process. `scip-dotnet` runs `dotnet restore`, a Roslyn build host and MSBuild worker nodes; `scip-java` runs Maven or Gradle and their JVMs. exec.CommandContext knows the first of them only: a timeout killed the launcher and left the rest, and a kivgraph that was itself killed left all of it.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CombinedOutput ¶
CombinedOutput is exec.Cmd.CombinedOutput for a tool that starts a tree: cancelling the context kills the tree, this process dying kills the tree, and whatever the tool left running when it returned is killed too -- build daemons and worker nodes that would idle for minutes holding memory for an index that is already written.
The command must come from exec.CommandContext.
func Contain ¶
Contain makes the command the leader of a process group of its own, so that what it starts can be found again, and makes cancelling its context kill the group rather than the one process. It is called before Start, on a command made with exec.CommandContext.
func Guard ¶
Guard makes a started command die with this process, and returns what to call once the command has been waited for. A contained command takes its whole group with it.
The Kill a caller runs when it is done only happens if the caller gets that far. A process ended by a timeout, by a harness or by the test runner never does, and what it started kept running: an analysis server that does not exit when its input closes, an indexer three processes deep building a solution nobody was waiting for any more.
Nothing portable ties a child to its parent's death: Linux has a signal for it and macOS has not. A pipe does it everywhere. The watcher blocks reading one whose only writer is this process, and the kernel closes that end whichever way this process ends.
It is a guard and not a dependency: without a shell to run it the command runs as it always did, and the leak this closes is back.
Types ¶
This section is empty.