proc

package
v0.9.3 Latest Latest
Warning

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

Go to latest
Published: Sep 21, 2026 License: MIT Imports: 3 Imported by: 0

Documentation

Index

Constants

View Source
const KillGrace = time.Second

KillGrace is how long a cancelled command has between SIGTERM and SIGKILL.

It is shorter than the 2s WaitDelay the callers set. When a command's shell exits on SIGTERM but a child that ignores it keeps the output pipes open, Wait returns at WaitDelay; the SIGKILL must land before that, or a caller that exits right after Wait (nib quitting) leaves the child running.

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 cancellation sends the group SIGTERM, then SIGKILL after KillGrace: a command gets a chance to clean up, and one that ignores SIGTERM is still stopped.

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