Fix channel buffer used with signal.Notify (#421)

Co-authored-by: Anbraten <anton@ju60.de>
This commit is contained in:
Masaya Watanabe 2021-10-09 10:14:25 +09:00 committed by GitHub
parent 01ebbd8c2d
commit 7913d6db95
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 2 additions and 2 deletions

View file

@ -26,7 +26,7 @@ func WithContext(ctx context.Context) context.Context {
func WithContextFunc(ctx context.Context, f func()) context.Context {
ctx, cancel := context.WithCancel(ctx)
go func() {
c := make(chan os.Signal)
c := make(chan os.Signal, 1)
signal.Notify(c, syscall.SIGINT, syscall.SIGTERM)
defer signal.Stop(c)

View file

@ -20,7 +20,7 @@ func WithContext(ctx context.Context) context.Context {
func WithContextFunc(ctx context.Context, f func()) context.Context {
ctx, cancel := context.WithCancel(ctx)
go func() {
c := make(chan os.Signal)
c := make(chan os.Signal, 1)
signal.Notify(c, os.Interrupt)
defer signal.Stop(c)