mirror of
https://github.com/MichaelMure/git-bug.git
synced 2024-12-14 08:45:30 +03:00
Inverted boolean check
This commit is contained in:
parent
f72b18496b
commit
85032d4cdc
@ -7,16 +7,17 @@ import (
|
||||
"syscall"
|
||||
)
|
||||
|
||||
// Cleaner type referes to a function with no inputs that returns an error
|
||||
type Cleaner func() error
|
||||
|
||||
var cleaners []Cleaner
|
||||
var inactive bool
|
||||
var active = false
|
||||
|
||||
// RegisterCleaner is responsible for regisreting a cleaner function. When a function is registered, the Signal watcher is started in a goroutine.
|
||||
func RegisterCleaner(f Cleaner) {
|
||||
cleaners = append(cleaners, f)
|
||||
if !inactive {
|
||||
inactive = false
|
||||
if !active {
|
||||
active = true
|
||||
go func() {
|
||||
ch := make(chan os.Signal, 1)
|
||||
signal.Notify(ch, syscall.SIGINT, syscall.SIGTERM, os.Interrupt)
|
||||
|
Loading…
Reference in New Issue
Block a user