proctree

package
v0.10.2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 23, 2026 License: Apache-2.0 Imports: 7 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

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

func CombinedOutput(cmd *exec.Cmd) ([]byte, error)

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

func Contain(cmd *exec.Cmd)

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

func Guard(cmd *exec.Cmd) (release func())

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.

func Output

func Output(cmd *exec.Cmd) ([]byte, error)

Output is exec.Cmd.Output with the same three guarantees: standard output is returned, and what the tool wrote to standard error travels in the *exec.ExitError of a tool that failed.

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL