signal

package
v0.4.1 Latest Latest
Warning

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

Go to latest
Published: Aug 9, 2024 License: Apache-2.0 Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NotifyContext

func NotifyContext(parent context.Context, signals ...os.Signal) context.Context

NotifyContext returns a derived context from the parent context with a cancel function. It sets up a signal channel to listen for the specified signals and cancels the context when any of those signals are received. If a second signal is received, it exits the program with a status code of 1.

Example usage:

ctx := signal.NotifyContext(parentContext, os.Interrupt, syscall.SIGTERM)
go func() {
    <-ctx.Done()
    // Perform cleanup or other tasks before exiting
}()

Types

This section is empty.

Jump to

Keyboard shortcuts

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