diff options
author | Rafael Passos <rafael@rcpassos.me> | 2018-10-24 18:55:02 -0300 |
---|---|---|
committer | Rafael Passos <rafael@rcpassos.me> | 2018-10-24 18:55:02 -0300 |
commit | 85032d4cdc43b23da620d9e6b81cb961127566d5 (patch) | |
tree | 5a6dee330bafaead0dcc439903d1fa435e65ad41 /util/interrupt/cleaner.go | |
parent | f72b18496b508c23cee6fa99d764cfe59208515c (diff) | |
download | git-bug-85032d4cdc43b23da620d9e6b81cb961127566d5.tar.gz |
Inverted boolean check
Diffstat (limited to 'util/interrupt/cleaner.go')
-rw-r--r-- | util/interrupt/cleaner.go | 7 |
1 files changed, 4 insertions, 3 deletions
diff --git a/util/interrupt/cleaner.go b/util/interrupt/cleaner.go index dfb8e25b..58dd6b07 100644 --- a/util/interrupt/cleaner.go +++ b/util/interrupt/cleaner.go @@ -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) |