1
0
mirror of https://github.com/docker/cli.git synced 2026-01-06 05:41:44 +03:00

Merge pull request #2986 from thaJeztah/ignore_nil_signals

ForwardAllSignals: check if channel is closed, and remove warning
This commit is contained in:
Silvin Lubecki
2021-05-25 10:29:42 +02:00
committed by GitHub

View File

@@ -2,7 +2,6 @@ package container
import (
"context"
"fmt"
"os"
gosignal "os/signal"
@@ -15,10 +14,16 @@ import (
//
// The channel you pass in must already be setup to receive any signals you want to forward.
func ForwardAllSignals(ctx context.Context, cli command.Cli, cid string, sigc <-chan os.Signal) {
var s os.Signal
var (
s os.Signal
ok bool
)
for {
select {
case s = <-sigc:
case s, ok = <-sigc:
if !ok {
return
}
case <-ctx.Done():
return
}
@@ -40,7 +45,6 @@ func ForwardAllSignals(ctx context.Context, cli command.Cli, cid string, sigc <-
}
}
if sig == "" {
fmt.Fprintf(cli.Err(), "Unsupported signal: %v. Discarding.\n", s)
continue
}