Extract client signals to pkg/signal

SIGCHLD and SIGWINCH used in api/client (cli code) are not
available on Windows. Extracting into separate files with build
tags.

Signed-off-by: Ahmet Alp Balkan <ahmetb@microsoft.com>
This commit is contained in:
Ahmet Alp Balkan 2014-11-13 10:40:22 -08:00
parent 975b6e598d
commit 91a86670aa
4 changed files with 28 additions and 5 deletions

View File

@ -18,7 +18,6 @@ import (
"runtime" "runtime"
"strconv" "strconv"
"strings" "strings"
"syscall"
"text/tabwriter" "text/tabwriter"
"text/template" "text/template"
"time" "time"
@ -608,7 +607,7 @@ func (cli *DockerCli) forwardAllSignals(cid string) chan os.Signal {
signal.CatchAll(sigc) signal.CatchAll(sigc)
go func() { go func() {
for s := range sigc { for s := range sigc {
if s == syscall.SIGCHLD { if s == signal.SIGCHLD {
continue continue
} }
var sig string var sig string
@ -619,7 +618,7 @@ func (cli *DockerCli) forwardAllSignals(cid string) chan os.Signal {
} }
} }
if sig == "" { if sig == "" {
log.Errorf("Unsupported signal: %d. Discarding.", s) log.Errorf("Unsupported signal: %v. Discarding.", s)
} }
if _, _, err := readBody(cli.call("POST", fmt.Sprintf("/containers/%s/kill?signal=%s", cid, sig), nil, false)); err != nil { if _, _, err := readBody(cli.call("POST", fmt.Sprintf("/containers/%s/kill?signal=%s", cid, sig), nil, false)); err != nil {
log.Debugf("Error sending signal: %s", err) log.Debugf("Error sending signal: %s", err)

View File

@ -14,12 +14,12 @@ import (
gosignal "os/signal" gosignal "os/signal"
"strconv" "strconv"
"strings" "strings"
"syscall"
log "github.com/Sirupsen/logrus" log "github.com/Sirupsen/logrus"
"github.com/docker/docker/api" "github.com/docker/docker/api"
"github.com/docker/docker/dockerversion" "github.com/docker/docker/dockerversion"
"github.com/docker/docker/engine" "github.com/docker/docker/engine"
"github.com/docker/docker/pkg/signal"
"github.com/docker/docker/pkg/stdcopy" "github.com/docker/docker/pkg/stdcopy"
"github.com/docker/docker/pkg/term" "github.com/docker/docker/pkg/term"
"github.com/docker/docker/registry" "github.com/docker/docker/registry"
@ -238,7 +238,7 @@ func (cli *DockerCli) monitorTtySize(id string, isExec bool) error {
cli.resizeTty(id, isExec) cli.resizeTty(id, isExec)
sigchan := make(chan os.Signal, 1) sigchan := make(chan os.Signal, 1)
gosignal.Notify(sigchan, syscall.SIGWINCH) gosignal.Notify(sigchan, signal.SIGWINCH)
go func() { go func() {
for _ = range sigchan { for _ = range sigchan {
cli.resizeTty(id, isExec) cli.resizeTty(id, isExec)

12
pkg/signal/signal_unix.go Normal file
View File

@ -0,0 +1,12 @@
// +build !windows
package signal
import (
"syscall"
)
// Signals used in api/client (no windows equivalent, use
// invalid signals so they don't get handled)
const SIGCHLD = syscall.SIGCHLD
const SIGWINCH = syscall.SIGWINCH

View File

@ -0,0 +1,12 @@
// +build windows
package signal
import (
"syscall"
)
// Signals used in api/client (no windows equivalent, use
// invalid signals so they don't get handled)
const SIGCHLD = syscall.Signal(0xff)
const SIGWINCH = syscall.Signal(0xff)