osctx

package
v0.3.0 Latest Latest
Warning

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

Go to latest
Published: Jun 20, 2024 License: Apache-2.0 Imports: 5 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func WithSignal

func WithSignal(parent unison.Canceler, sigs ...os.Signal) (context.Context, context.CancelFunc)

WithSignal creates a context that will be cancelled if any of the configured signals is received by the process. The signal handler will be removed automatically in case the parent context gets cancelled or when the cancel function is called.

The context should be used to trigger application shutdown. If the signal is received again, the signal handler will force shutdown the process with exit code 3.

example:

 func main() {
		ctx, cancel := osctx.WithSignal(context.Background(), os.Kill)
		defer cancel()

		for ctx.Err == nil {
			// main run loop
		}
 }

Types

This section is empty.

Jump to

Keyboard shortcuts

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