sighandler

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Apr 27, 2024 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func WithCancelOnSigInt

func WithCancelOnSigInt(parent context.Context) context.Context

WithCancelOnSigInt creates a child context that can be cancelled when a SIGINT signal (Ctrl+C) is received. The parent context is passed as an argument and the function returns the created child context.

The function starts a goroutine to listen for the SIGINT signal and calls the cancel function of the child context when the signal is received.

Example usage:

parentCtx := context.Background()
childCtx := WithCancelOnSigInt(parentCtx)
// use childCtx in your code...

Types

This section is empty.

Jump to

Keyboard shortcuts

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