signal

package
v0.68.12 Latest Latest
Warning

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

Go to latest
Published: Nov 12, 2024 License: MIT Imports: 4 Imported by: 0

Documentation

Overview

Package signal provides convenience methods for intercepting and handling OS signals.

Index

Constants

This section is empty.

Variables

View Source
var InterruptSignal = syscall.SIGINT //nolint:gochecknoglobals

InterruptSignal is an interrupt signal.

View Source
var InterruptSignals = []os.Signal{syscall.SIGTERM, syscall.SIGINT} //nolint:gochecknoglobals

InterruptSignals contains a list of signals that are treated as interrupts.

Functions

func Notifier

func Notifier(notifyFn NotifyFunc, trackSignals ...os.Signal)

Notifier registers a handler for receiving signals from the OS. When signal is receiving, it calls the given callback func `notifyFn`.

func NotifierWithContext

func NotifierWithContext(ctx context.Context, notifyFn NotifyFunc, trackSignals ...os.Signal)

NotifierWithContext does the same as `Notifier`, but if the given `ctx` becomes `Done`, the notification is stopped.

Types

type ContextCanceledError

type ContextCanceledError struct {
	Signal os.Signal
}

ContextCanceledError contains a signal to pass through when the context is cancelled.

func NewContextCanceledError

func NewContextCanceledError(sig os.Signal) *ContextCanceledError

NewContextCanceledError returns a new `ContextCanceledError` instance.

func (ContextCanceledError) Error

func (ContextCanceledError) Error() string

Error implements the `Error` method.

func (ContextCanceledError) Unwrap

func (ContextCanceledError) Unwrap() error

Unwrap implements the `Unwrap` method.

type NotifyFunc

type NotifyFunc func(sig os.Signal)

NotifyFunc is a callback function for Notifier.

Jump to

Keyboard shortcuts

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