Categorygithub.com/aklinkert/go-exitcontext
modulepackage
1.1.0
Repository: https://github.com/aklinkert/go-exitcontext.git
Documentation: pkg.go.dev

# README

go-exitcontext

This package provides functions to create a context that listens for SIG_ signals and cancels the context, used to abort programs by sending signals.

Usage

If you already have a context and want to recycle that one:

ctx := context.Background()
exitCtx := exitcontext.NewWithContext(ctx)

else just use the new method, which creates a context.Background() under the hood:

exitCtx := exitcontext.New()

License

MIT License

Copyright (c) 2019 Alexander Pinnecke

# Functions

New uses a default background context to create the exit handler.
NewWithContext returns a context instance that gets cancelled if the process receives a SIGTERM or a SIGINT.