Skip to content
This repository was archived by the owner on Aug 26, 2026. It is now read-only.

Latest commit

 

History

5 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Deprecation notice

This library is depracted in favor of signal.NotifyContext. This repository will be archived and no more maintaned.

go.bug.st/cleanup

This library provides a signal.Interrupt/CTRL-C interruptable context for golang.

The intended usage is as follows:

ctx, cancel := cleanup.InterruptableContext(wrappedContext)
defer cancel() // release the CTRL-C hook, see below

// Execute a long operation that may be interrupted
err := VeryLongOperation(ctx)

// If VeryLongOperation is interrupted with CTRL-C or if it gets a signal.Interrupt
// then an err "interrupted" is returned (instead of terminating the process).
if err != nil && err.Error() == "interrupted" {
    // We've been interrupted
    [...do something...]
}

// when defer cancel() is executed the signal.Interrupt is no more hooked to the
// context and the resource is freed

About

This library provides a signal.Interrupt/CTRL-C interruptable context for golang.

Resources

Stars

3 stars

Watchers

1 watching

Forks

Releases

Packages

Contributors

Languages