mirror of https://github.com/docker/cli.git
Merge pull request #2986 from thaJeztah/ignore_nil_signals
ForwardAllSignals: check if channel is closed, and remove warning
This commit is contained in:
commit
e26409ebf1
|
@ -2,7 +2,6 @@ package container
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
"fmt"
|
|
||||||
"os"
|
"os"
|
||||||
gosignal "os/signal"
|
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.
|
// 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) {
|
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 {
|
for {
|
||||||
select {
|
select {
|
||||||
case s = <-sigc:
|
case s, ok = <-sigc:
|
||||||
|
if !ok {
|
||||||
|
return
|
||||||
|
}
|
||||||
case <-ctx.Done():
|
case <-ctx.Done():
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
@ -40,7 +45,6 @@ func ForwardAllSignals(ctx context.Context, cli command.Cli, cid string, sigc <-
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if sig == "" {
|
if sig == "" {
|
||||||
fmt.Fprintf(cli.Err(), "Unsupported signal: %v. Discarding.\n", s)
|
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue