exitcontext

package module
v1.1.0 Latest Latest
Warning

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

Go to latest
Published: Feb 18, 2020 License: MIT Imports: 4 Imported by: 2

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

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func New

func New() context.Context

New uses a default background context to create the exit handler

func NewWithContext

func NewWithContext(ctx context.Context) context.Context

NewWithContext returns a context instance that gets cancelled if the process receives a SIGTERM or a SIGINT.

Types

This section is empty.

Jump to

Keyboard shortcuts

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