executil

package
v0.1.7 Latest Latest
Warning

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

Go to latest
Published: Nov 23, 2026 License: AGPL-3.0 Imports: 16 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 executil wraps os/exec so child processes can be hidden on Windows.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AugmentProcessPath added in v0.0.11

func AugmentProcessPath()

AugmentProcessPath makes the process PATH look like the user's, not like the launcher's. A daemon started by launchd, a systemd user unit, or the Windows task scheduler inherits a minimal PATH — /usr/bin:/bin:… on macOS, a service-style PATH on Windows — while the agent CLIs (claude, codex, opencode, …) live in per-user or package-manager directories that PATH never contains. The node then advertises zero agents in its capability summary and peers route no work to it: devices are "online" yet a coding task finds no executor. Called once at daemon startup, before any adapter or agent lookup, so every LookPath downstream (dispatchability filters, pyexec, adapter probes) sees the same PATH an interactive shell would.

Entries are appended only when the directory exists and is not already on PATH, and the process environment is rewritten in place (children inherit it). Safe to call more than once.

func CommandContext

func CommandContext(ctx context.Context, name string, args ...string) *exec.Cmd

CommandContext builds an exec.Cmd whose cancellation kills the whole process group, not just the direct child (P1-17). Without this, a cancelled python adapter would die while the claude CLI it spawned kept running as an orphan — burning tokens and holding file locks. The child is put in its own process group (Setpgid) so Cancel can signal the group by negative pid.

Cancel escalates TERM → KILL instead of going straight to SIGKILL: the adapter harness deliberately spawns the agent CLI in ITS OWN session (start_new_session), unreachable from the adapter's process group. A bare SIGKILL removes the adapter before its watchdog can take the CLI tree down — SIGTERM gives the adapter's handler the one beat it needs to kill its children and exit. A group that ignores TERM still dies at termGrace.

Types

type Capture

type Capture struct {
	// contains filtered or unexported fields
}

Capture is an io.Writer that accumulates output up to captureCap bytes, then appends a truncation marker once and discards further writes. It always reports the full write length so the child never sees a short-write error.

func (*Capture) Bytes

func (c *Capture) Bytes() []byte

Bytes returns the captured output.

func (*Capture) String

func (c *Capture) String() string

String returns the captured output as text for result payloads. On Windows the bytes may be the console codepage rather than UTF-8 (PowerShell, cmd and Python on zh-CN write GBK to a redirected pipe); normalizeConsoleText transcodes those, because Go's JSON encoder would otherwise replace every non-ASCII byte with U+FFFD and the delegator would read mojibake for text that was fine on the executor.

func (*Capture) Write

func (c *Capture) Write(p []byte) (int, error)

Write appends p to the capture buffer, truncating once it would exceed the cap. The reported n is always len(p).

Jump to

Keyboard shortcuts

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