Skip to content
This repository has been archived by the owner on Nov 26, 2023. It is now read-only.

Commit

Permalink
refactor signal vars
Browse files Browse the repository at this point in the history
  • Loading branch information
davidmdm committed Oct 20, 2023
1 parent bd62134 commit 8a781d6
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion signal.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ func WithSignalCancelation(parent context.Context, signals ...os.Signal) (ctx co
signalCh = make(chan os.Signal, 1)
done = make(chan struct{})
stop = make(chan struct{})
once = sync.Once{}
)

signal.Notify(signalCh, signals...)
Expand All @@ -36,6 +35,8 @@ func WithSignalCancelation(parent context.Context, signals ...os.Signal) (ctx co
cancelCause(nil)
}()

var once sync.Once

cancel = func() {
once.Do(func() { close(stop) })
<-done
Expand Down

0 comments on commit 8a781d6

Please sign in to comment.