interrupt

package
v1.25.5 Latest Latest
Warning

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

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

Documentation

Overview

Package interrupt runs registered cleanup when ddev receives Ctrl-C, SIGTERM, or SIGHUP, so that an interrupted command does not leave temporary containers or a raw-mode terminal behind.

Code that handles some of these signals itself calls Delegate() while it does, and the handler then runs the cleanup for those without exiting.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Delegate

func Delegate(sigs ...os.Signal) (release func())

Delegate tells the handler that the caller handles sigs itself, so for those the handler runs the cleanup but leaves exiting to the caller. Call the returned release function when the caller stops handling them.

func ExitCode

func ExitCode(sig os.Signal) int

ExitCode returns the shell convention 128+signal number for sig.

func Install

func Install()

Install starts the handler. It is safe to call more than once.

func OnInterrupt

func OnInterrupt(f func(context.Context)) (unregister func())

OnInterrupt registers f to run on every interrupt until unregister is called. f runs more than once when a caller has delegated, and should give up when ctx is done.

func Run

func Run(fns []func(context.Context), timeout time.Duration)

Run calls each cleanup function in parallel and waits for them to return or for timeout to pass.

func WaitIfExiting

func WaitIfExiting()

WaitIfExiting blocks for good once the handler has begun cleaning up before exiting. Fatal error paths call it, because cleanup such as removing a container makes in-flight work fail, and exiting on that failure would beat the handler and report an error instead of the signal.

Types

This section is empty.

Jump to

Keyboard shortcuts

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