Documentation
¶
Overview ¶
Package execx provides explicit helpers for spawning subprocesses with a chosen TTY attachment mode, replacing env-var signalling with real OS state.
Use NonInteractive when the subprocess must not prompt (tests, automation, hooks that shouldn't block). Use Interactive when the subprocess should inherit the parent's controlling TTY (the default for exec.Command).
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func NonInteractive ¶
NonInteractive returns an *exec.Cmd detached from the parent's controlling TTY. In the child, /dev/tty cannot be opened, so interactive.CanPromptInteractively() returns false — no env var required.
On Windows the child runs with DETACHED_PROCESS | CREATE_NEW_PROCESS_GROUP so it has no inherited console.
func SpawnDetached ¶ added in v0.9.0
SpawnDetached re-execs the current executable as a detached, fire-and-forget child running args, surviving the parent's exit (new session on Unix, CREATE_NEW_PROCESS_GROUP | DETACHED_PROCESS on Windows, via detachFromTTY). The child runs in dir (os.TempDir() when empty, so the child never holds the parent's working directory), inherits the parent's environment, and has its stdout/stderr discarded. Best-effort: every error is swallowed — callers treat the spawn as advisory background work.
In-process `go test` runs are a no-op: the current executable is the test binary, and re-execing it would fork the whole suite. Tests exercise the call sites through their spawn seams instead.
Types ¶
This section is empty.