Skip to content

Commit 18466a2

Browse files
committed
Avoid printing a signal error when closing a connection
Previously I would see: ``` dave@m1 cli % ./build/docker run -it --init ubuntu root@7f9fc6aee300:/# exit Unsupported signal: <nil>. Discarding. ``` Signed-off-by: David Scott <[email protected]>
1 parent cedaf44 commit 18466a2

1 file changed

Lines changed: 7 additions & 1 deletion

File tree

cli/command/container/signals.go

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,13 +16,19 @@ import (
1616
// The channel you pass in must already be setup to receive any signals you want to forward.
1717
func ForwardAllSignals(ctx context.Context, cli command.Cli, cid string, sigc <-chan os.Signal) {
1818
var s os.Signal
19+
var ok bool
1920
for {
2021
select {
21-
case s = <-sigc:
22+
case s, ok = <-sigc:
2223
case <-ctx.Done():
2324
return
2425
}
2526

27+
if !ok {
28+
// channel closed: session is over
29+
return
30+
}
31+
2632
if s == signal.SIGCHLD || s == signal.SIGPIPE {
2733
continue
2834
}

0 commit comments

Comments
 (0)