proc

package
v0.7.0 Latest Latest
Warning

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

Go to latest
Published: Sep 11, 2026 License: MIT Imports: 2 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Group

func Group(cmd *exec.Cmd)

Group makes cmd run in its own process group and cancel by killing that whole group. It must be called before cmd.Start, which is when the context watchdog captures Cancel.

Without it, exec.CommandContext's default cancel kills only the DIRECT child. Every caller here runs its command through `sh -c`, and /bin/sh (dash) forks the command rather than exec'ing it — so the real work is a grandchild that survives the kill, keeps running, and keeps the stdout/stderr pipe write ends it inherited open. cmd.Wait does not return until those pipes reach EOF, so cancelling neither stopped the work nor promptly unblocked the caller.

Setpgid puts the child in a new group whose id is its own pid, so kill(-pid) reaches the shell and everything it spawned, and nothing else.

Two behavior notes for callers. The command no longer shares nib's process group, so a terminal-generated SIGINT no longer reaches it directly; cancellation still does, through the context. And the group is terminated with SIGKILL, so a command that would previously have received a graceful SIGINT gets no chance to clean up.

Group does not set cmd.WaitDelay. A command that daemonizes with setsid() escapes the group and can still hold the pipes open, so callers that must not block indefinitely set their own delay with their own rationale.

Types

This section is empty.

Jump to

Keyboard shortcuts

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