procsignal

package
v0.8.1 Latest Latest
Warning

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

Go to latest
Published: Jul 7, 2026 License: MIT Imports: 2 Imported by: 0

Documentation

Overview

Package procsignal records the OS signal, if any, that initiated process shutdown. It gives the CLI a single source of truth for "were we signalled?" shared by the two places that can observe a terminating signal:

  • the top-level signal handler in cmd/entire, which cancels the root context on SIGINT/SIGTERM, and
  • the keyring interrupt path in internal/entireclient/tokenstore, which detects Ctrl-C via its own signal.Notify listener so a stuck keyring read unblocks immediately.

Before this package the two mechanisms were uncoordinated: the keyring path returned a context.Canceled error while the top-level handler stored the caught signal asynchronously on a different goroutine, so the CLI's signal-abort gate could read the store before it was set and misreport a user abort as a failure (and fail to break an enclosing shell loop). Recording the signal here — on the same goroutine that unwinds to the gate — removes that race.

Tech debt: this shared global exists only because auth-go's Store interface (LoadTokens/SaveTokens) carries no context.Context, so the keyring path can't ride the root context and instead detects Ctrl-C via its own signal listener. Once that interface accepts a context, keyring cancellation can flow from the root context like everything else, the tokenstore signal listener can go away, and this package with it.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Load

func Load() os.Signal

Load returns the recorded terminating signal, or nil if none was recorded.

func Reset

func Reset()

Reset clears the recorded signal. It exists for tests that need a clean slate; production code never clears it (the process is on its way out).

func Store

func Store(sig os.Signal)

Store records sig as the signal that initiated shutdown. Safe for concurrent use; last writer wins, which is fine because every caller stores a genuine terminating signal.

Types

This section is empty.

Jump to

Keyboard shortcuts

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