Skip to content

Commit

Permalink
cmd/docker: fix possible race between ctx channel and signal channel
Browse files Browse the repository at this point in the history
Signed-off-by: Alano Terblanche <[email protected]>
  • Loading branch information
Benehiko committed Jan 24, 2025
1 parent 77760e2 commit 49b52e8
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions cmd/docker/docker.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ func notifyContext(ctx context.Context, signals ...os.Signal) (context.Context,
ch := make(chan os.Signal, 1)
signal.Notify(ch, signals...)

ctx, cancel := context.WithCancelCause(ctx)
ctxCause, cancel := context.WithCancelCause(ctx)

go func() {
select {
Expand All @@ -57,7 +57,7 @@ func notifyContext(ctx context.Context, signals ...os.Signal) (context.Context,
}
}()

return ctx, func() {
return ctxCause, func() {
signal.Stop(ch)
cancel(nil)
}
Expand Down

0 comments on commit 49b52e8

Please sign in to comment.