Documentation
¶
Overview ¶
Package detach re-execs the current binary as a detached background child so a hook-invoked command can return control to Claude Code immediately and never block the session (FR-3 / HOOK-3 / DX-6).
We deliberately do NOT shell out to `setsid` (absent on macOS and Windows Git Bash). Instead the parent re-execs itself with stdio detached and an env marker set; the OS-specific SysProcAttr (Setsid on unix, DETACHED_PROCESS on Windows) fully detaches the child. Self-detach is the primary non-blocking guarantee, independent of Claude Code honoring the hook `async` field.
Index ¶
Constants ¶
const EnvMarker = "PROMPTVM_SYNC_DETACHED"
EnvMarker is set on the detached child's environment. The command checks it to know it is the background worker and must not re-detach (avoiding a fork bomb).
Variables ¶
This section is empty.
Functions ¶
func IsChild ¶
func IsChild() bool
IsChild reports whether the current process is the detached background child.
func Reexec ¶
Reexec launches a detached copy of this binary with the same arguments and a copy of stdin redirected from the provided file (so the child can still read the hook payload). It returns the child PID. The caller (parent) should exit 0 immediately after a successful Reexec.
stdinPath, when non-empty, is opened read-only and wired to the child's stdin; this lets the parent persist the hook's stdin to a temp file and hand it to the detached child, since the original stdin pipe closes when the parent returns.
Types ¶
This section is empty.