Documentation
¶
Overview ¶
Package procutil abstracts the per-OS process plumbing the agent needs:
- Detach marks a child so it neither dies with the turn nor receives the terminal's ctrl-c, and so killing it takes its whole tree.
- Alive reports whether a pid is still running (signal 0 on unix, OpenProcess + exit-code query on Windows, where os.FindProcess always succeeds).
- KillTree stops a process and everything it started (negative-pid group kill on unix, taskkill /T on Windows where process-group semantics do not exist and a Job Object handle would not survive the turn boundary).
Index ¶
- func Alive(pid int) bool
- func ConsoleName() string
- func Detach(cmd *exec.Cmd)
- func DetachProcessGroup(cmd *exec.Cmd)
- func InterruptSignals() []os.Signal
- func KillProcessGroup(cmd *exec.Cmd)
- func KillTree(pid int) error
- func MediateMCPCommand(command string, args []string) (string, []string)
- func OpenConsole() (*os.File, error)
- func ResolveShell() (string, error)
- func RestoreTerminal()
- func ShellNameForPrompt() string
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ConsoleName ¶
func ConsoleName() string
ConsoleName is the path OpenConsole opens, for error messages.
func Detach ¶
Detach detaches cmd so it outlives the turn's iterations and can be killed as a tree. It must be called before cmd.Start.
func DetachProcessGroup ¶
DetachProcessGroup marks cmd as its own process group (Setpgid variant used by short-lived Shell tool children, as opposed to the Setsid session used for background processes).
func InterruptSignals ¶
InterruptSignals is what cancels a turn: SIGINT always, plus SIGTERM where the OS has one. The agent's double-ctrl-c path (first cancels the turn, second exits 130) is shared; only the set differs per OS.
func KillProcessGroup ¶
KillProcessGroup kills the process group of an already-started command. It is the exec.Cmd variant of KillTree for callers that hold the child.
func KillTree ¶
KillTree stops pid and everything it started. Killing an already-dead process is not an error.
func MediateMCPCommand ¶
MediateMCPCommand returns the command and args to spawn for an MCP stdio server. On unix the resolved command runs directly.
func OpenConsole ¶
OpenConsole opens the controlling terminal for a direct confirmation read.
func ResolveShell ¶
ResolveShell returns the POSIX shell to run agent commands through. On unix it is always "sh" (exec.LookPath resolution happens at spawn time so the error surfaces where the command runs).
func RestoreTerminal ¶
func RestoreTerminal()
RestoreTerminal resets a garbled terminal after the agent exits. On unix this is `stty sane` against the controlling terminal.
func ShellNameForPrompt ¶
func ShellNameForPrompt() string
ShellNameForPrompt reports the shell for the environment prompt block.
Types ¶
This section is empty.