proc

package
v0.20.1 Latest Latest
Warning

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

Go to latest
Published: Jul 30, 2026 License: Apache-2.0 Imports: 7 Imported by: 0

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.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Run

func Run(cmd *exec.Cmd) error

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

func RunInPTY(cmd *exec.Cmd, out io.Writer) (started bool, err error)

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).

No new session is created, so the child stays in lstk's process group and still gets Ctrl-C directly. started is false if no PTY could be allocated (e.g. Windows); the caller should fall back to Run.

Types

This section is empty.

Jump to

Keyboard shortcuts

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