Skip to content

Commit

Permalink
Default to no action on cancelation to avoid unexpected exit
Browse files Browse the repository at this point in the history
  • Loading branch information
lammel committed May 27, 2023
1 parent 83125e3 commit e3e345a
Showing 1 changed file with 3 additions and 9 deletions.
12 changes: 3 additions & 9 deletions internal/cancelation_signal.go
Original file line number Diff line number Diff line change
@@ -1,22 +1,16 @@
package internal

import "os"

// NewCancelationSignal for keeping track of a cancelation
func NewCancelationSignal(exitFunc func()) (func(), func()) {
func NewCancelationSignal(interruptFunc func()) (func(), func()) {
canceled := false

cancel := func() {
canceled = true
}

if exitFunc == nil {
exitFunc = func() { os.Exit(1) }
}

exit := func() {
if canceled {
exitFunc()
if canceled && interruptFunc != nil {
interruptFunc()
}
}

Expand Down

0 comments on commit e3e345a

Please sign in to comment.