Documentation
¶
Overview ¶
Package proc runs wrapped external tools (aws, terraform, cdk, sam, az, and extensions) so that termination signals reach the child gracefully instead of hard-killing it, and lets a caller record whose failure a non-zero exit was (MarkUserToolExit) — a separate claim from having run through Run.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func IsUserToolExit ¶ added in v1.4.0
IsUserToolExit backs result.proxy_exit_code on lstk_command telemetry events (see cmd.commandResult).
func MarkUserToolExit ¶ added in v1.4.0
MarkUserToolExit marks a wrapped tool the user asked for exiting non-zero, so telemetry attributes the failure to them rather than to lstk.
Call it only where the invocation is the user's; running through Run is not that claim. lstk shells out for its own purposes too, and marking one of those hides an lstk bug behind the user's name.
func Run ¶
Run starts cmd, waits for it to exit, and returns the same error cmd.Run would. It ensures SIGINT/SIGTERM reach the wrapped tool exactly once so it can clean up instead of being SIGKILLed the instant lstk's context is cancelled.
When cmd was created with exec.CommandContext, its default Cancel hard-kills the child (SIGKILL) as soon as the context is done — which is exactly what happens on Ctrl-C, since lstk cancels its root context on SIGINT/SIGTERM. Run disarms that: a cancelled context no longer kills the child, so the tool terminates from the signal it receives and lstk waits for it to finish its own shutdown. Returning os.ErrProcessDone from Cancel both suppresses the kill and avoids injecting context.Canceled into the wait result, so the tool's real exit code is preserved.
Received signals are relayed per shouldForward: SIGTERM always, SIGINT only when lstk is not attached to a terminal (an attached terminal already delivers Ctrl-C to the child via the foreground process group). npm/launcher.js forwards unconditionally instead — safe there because its child is lstk, which tolerates duplicate signals; wrapped tools like terraform do not.
func RunInPTY ¶ added in v0.20.1
RunInPTY runs cmd like Run, but gives the child a pseudo-terminal instead of a plain pipe for stdout/stderr, copying its output to out. Over a pipe, e.g. the Python aws CLI block-buffers stdout (ignoring PYTHONUNBUFFERED), holding back streaming commands like `logs tail --follow` until exit; a PTY makes it detect a terminal and stay line-buffered (DEVX-1026).
When cmd.Stdin is itself a terminal, the PTY additionally becomes the child's stdin and controlling terminal, with keystrokes pumped into it from the real terminal — see wireInteractiveStdin for why (DEVX-1049). Otherwise (stdin redirected, `yes | lstk aws ...`) stdin stays wired as given and no new session is created, so piped data never passes through a terminal's line discipline and the child stays in lstk's process group, still getting Ctrl-C directly. started is false if no PTY could be allocated; the caller should fall back to Run.
func WasInterrupted ¶ added in v1.4.0
WasInterrupted reports that the user's Ctrl-C reached the child through RunInPTY's keystroke pump. In that mode the PTY's line discipline delivers SIGINT to the child alone, so lstk's own signal context never fires and this is telemetry's only evidence of the interruption (result.cancelled).
Types ¶
This section is empty.