Skip to content

Commit

Permalink
Extract client signals to pkg/signal
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
ahmetb committed Nov 15, 2014
1 parent 975b6e5 commit 91a8667
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 5 deletions.
5 changes: 2 additions & 3 deletions api/client/commands.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ import (
"runtime"
"strconv"
"strings"
"syscall"
"text/tabwriter"
"text/template"
"time"
Expand Down Expand Up @@ -608,7 +607,7 @@ func (cli *DockerCli) forwardAllSignals(cid string) chan os.Signal {
signal.CatchAll(sigc)
go func() {
for s := range sigc {
if s == syscall.SIGCHLD {
if s == signal.SIGCHLD {
continue
}
var sig string
Expand All @@ -619,7 +618,7 @@ func (cli *DockerCli) forwardAllSignals(cid string) chan os.Signal {
}
}
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 {
log.Debugf("Error sending signal: %s", err)
Expand Down
4 changes: 2 additions & 2 deletions api/client/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,12 @@ import (
gosignal "os/signal"
"strconv"
"strings"
"syscall"

log "github.com/Sirupsen/logrus"
"github.com/docker/docker/api"
"github.com/docker/docker/dockerversion"
"github.com/docker/docker/engine"
"github.com/docker/docker/pkg/signal"
"github.com/docker/docker/pkg/stdcopy"
"github.com/docker/docker/pkg/term"
"github.com/docker/docker/registry"
Expand Down Expand Up @@ -238,7 +238,7 @@ func (cli *DockerCli) monitorTtySize(id string, isExec bool) error {
cli.resizeTty(id, isExec)

sigchan := make(chan os.Signal, 1)
gosignal.Notify(sigchan, syscall.SIGWINCH)
gosignal.Notify(sigchan, signal.SIGWINCH)
go func() {
for _ = range sigchan {
cli.resizeTty(id, isExec)
Expand Down
12 changes: 12 additions & 0 deletions pkg/signal/signal_unix.go
Original file line number Diff line number Diff line change
@@ -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
12 changes: 12 additions & 0 deletions pkg/signal/signal_windows.go
Original file line number Diff line number Diff line change
@@ -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)

0 comments on commit 91a8667

Please sign in to comment.