procgroup

package
v0.0.35 Latest Latest
Warning

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

Go to latest
Published: Sep 11, 2026 License: Apache-2.0 Imports: 3 Imported by: 0

Documentation

Overview

Package procgroup puts a child process in its own process group so a context cancellation kills the WHOLE group — not just the direct child. A shell command can spawn grandchildren (e.g. `sh -c "sleep 5"` or a backgrounded `make` with compiler children); killing only the shell orphans them, and a grandchild holding the stdout/stderr pipes makes (*exec.Cmd).Wait block until it exits — defeating the caller's timeout/cancel. Configure(cmd) installs Setpgid plus a Cancel that signals the negative PID, delivering SIGKILL to every process in the group so the pipes close promptly and Run honours its deadline. Shared by the hook runner (hookexec) and the Shell command runner (osfs).

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Configure

func Configure(c *exec.Cmd)

Configure puts cmd in its own process group and, on context cancellation, kills the entire group rather than just the leader. Signalling the negative PID delivers SIGKILL to every process in the group, so orphaned grandchildren die with their parent and any pipes they inherited close promptly.

func GroupAlive added in v0.0.26

func GroupAlive(pid int) bool

GroupAlive reports whether the managed process group remains alive. It does not inspect escaped descendants, which are outside the managed contract.

func Kill added in v0.0.26

func Kill(pid int) error

Kill terminates the managed process group. A vanished group is already done.

func Supported added in v0.0.22

func Supported() bool

Supported reports whether this platform can contain a whole command tree.

func WaitGone added in v0.0.26

func WaitGone(pid int, limit time.Duration) bool

WaitGone gives a cancellation kill a bounded chance to finish reaping the complete managed group before its lease is considered for immediate deletion.

Types

This section is empty.

Jump to

Keyboard shortcuts

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