Skip to content

Commit e26409e

Browse files
Merge pull request #2986 from thaJeztah/ignore_nil_signals
ForwardAllSignals: check if channel is closed, and remove warning
2 parents 86e1f04 + 9342ec6 commit e26409e

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

cli/command/container/signals.go

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ package container
22

33
import (
44
"context"
5-
"fmt"
65
"os"
76
gosignal "os/signal"
87

@@ -15,10 +14,16 @@ import (
1514
//
1615
// The channel you pass in must already be setup to receive any signals you want to forward.
1716
func ForwardAllSignals(ctx context.Context, cli command.Cli, cid string, sigc <-chan os.Signal) {
18-
var s os.Signal
17+
var (
18+
s os.Signal
19+
ok bool
20+
)
1921
for {
2022
select {
21-
case s = <-sigc:
23+
case s, ok = <-sigc:
24+
if !ok {
25+
return
26+
}
2227
case <-ctx.Done():
2328
return
2429
}
@@ -40,7 +45,6 @@ func ForwardAllSignals(ctx context.Context, cli command.Cli, cid string, sigc <-
4045
}
4146
}
4247
if sig == "" {
43-
fmt.Fprintf(cli.Err(), "Unsupported signal: %v. Discarding.\n", s)
4448
continue
4549
}
4650

0 commit comments

Comments
 (0)