clisignal

package
v1.0.63 Latest Latest
Warning

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

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

Documentation

Overview

Package clisignal shares process interruption semantics between CLI entrypoints.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Escalate

func Escalate(sig os.Signal)

func ExitCode

func ExitCode(sig os.Signal) int

func Redeliver

func Redeliver(sig os.Signal, findProcess func(int) (*os.Process, error), exitProcess func(int))

Redeliver asks the current process to handle the second signal with the platform's default semantics. Platforms that cannot deliver the requested signal through os.Process.Signal fall back to the conventional CLI exit status instead of leaving the process running after escalation.

Types

type Interruption

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

func NewInterruption

func NewInterruption(sig os.Signal) *Interruption

NewInterruption retains the first signal as the primary cancellation cause.

func (*Interruption) Error

func (e *Interruption) Error() string

func (*Interruption) ExitCode

func (e *Interruption) ExitCode() int

func (*Interruption) Subtype

func (e *Interruption) Subtype() string

func (*Interruption) Unwrap

func (e *Interruption) Unwrap() error

func (*Interruption) WithCancellationDetail

func (e *Interruption) WithCancellationDetail(err error) *Interruption

WithCancellationDetail keeps the signal as the primary process error while retaining actionable context from a command that stopped because of that signal. Plain context cancellation and nested signal errors add no useful detail, and unrelated command failures must not be relabelled as part of the interruption. The detail is deliberately not exposed through Unwrap so an inner structured error cannot override the signal's exit code or subtype.

type State

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

State records the first signal and the publication state observed with it. The zero value is ready for use.

func Install

func Install(parent context.Context, primaryCompleted func() bool) (context.Context, *State, func())

func Manage

func Manage(
	parent context.Context,
	primaryCompleted func() bool,
	signals <-chan os.Signal,
	stopNotify func(),
	escalate func(os.Signal),
) (context.Context, *State, func())

func (*State) Outcome

func (s *State) Outcome() (*Interruption, bool)

func (*State) Record

func (s *State) Record(sig os.Signal, primaryCompleted func() bool) (first bool)

Jump to

Keyboard shortcuts

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