Browse code

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>

Ahmet Alp Balkan authored on 2014/11/14 03:40:22
Showing 4 changed files
... ...
@@ -18,7 +18,6 @@ import (
18 18
 	"runtime"
19 19
 	"strconv"
20 20
 	"strings"
21
-	"syscall"
22 21
 	"text/tabwriter"
23 22
 	"text/template"
24 23
 	"time"
... ...
@@ -608,7 +607,7 @@ func (cli *DockerCli) forwardAllSignals(cid string) chan os.Signal {
608 608
 	signal.CatchAll(sigc)
609 609
 	go func() {
610 610
 		for s := range sigc {
611
-			if s == syscall.SIGCHLD {
611
+			if s == signal.SIGCHLD {
612 612
 				continue
613 613
 			}
614 614
 			var sig string
... ...
@@ -619,7 +618,7 @@ func (cli *DockerCli) forwardAllSignals(cid string) chan os.Signal {
619 619
 				}
620 620
 			}
621 621
 			if sig == "" {
622
-				log.Errorf("Unsupported signal: %d. Discarding.", s)
622
+				log.Errorf("Unsupported signal: %v. Discarding.", s)
623 623
 			}
624 624
 			if _, _, err := readBody(cli.call("POST", fmt.Sprintf("/containers/%s/kill?signal=%s", cid, sig), nil, false)); err != nil {
625 625
 				log.Debugf("Error sending signal: %s", err)
... ...
@@ -14,12 +14,12 @@ import (
14 14
 	gosignal "os/signal"
15 15
 	"strconv"
16 16
 	"strings"
17
-	"syscall"
18 17
 
19 18
 	log "github.com/Sirupsen/logrus"
20 19
 	"github.com/docker/docker/api"
21 20
 	"github.com/docker/docker/dockerversion"
22 21
 	"github.com/docker/docker/engine"
22
+	"github.com/docker/docker/pkg/signal"
23 23
 	"github.com/docker/docker/pkg/stdcopy"
24 24
 	"github.com/docker/docker/pkg/term"
25 25
 	"github.com/docker/docker/registry"
... ...
@@ -238,7 +238,7 @@ func (cli *DockerCli) monitorTtySize(id string, isExec bool) error {
238 238
 	cli.resizeTty(id, isExec)
239 239
 
240 240
 	sigchan := make(chan os.Signal, 1)
241
-	gosignal.Notify(sigchan, syscall.SIGWINCH)
241
+	gosignal.Notify(sigchan, signal.SIGWINCH)
242 242
 	go func() {
243 243
 		for _ = range sigchan {
244 244
 			cli.resizeTty(id, isExec)
245 245
new file mode 100644
... ...
@@ -0,0 +1,12 @@
0
+// +build !windows
1
+
2
+package signal
3
+
4
+import (
5
+	"syscall"
6
+)
7
+
8
+// Signals used in api/client (no windows equivalent, use
9
+// invalid signals so they don't get handled)
10
+const SIGCHLD = syscall.SIGCHLD
11
+const SIGWINCH = syscall.SIGWINCH
0 12
new file mode 100644
... ...
@@ -0,0 +1,12 @@
0
+// +build windows
1
+
2
+package signal
3
+
4
+import (
5
+	"syscall"
6
+)
7
+
8
+// Signals used in api/client (no windows equivalent, use
9
+// invalid signals so they don't get handled)
10
+const SIGCHLD = syscall.Signal(0xff)
11
+const SIGWINCH = syscall.Signal(0xff)