Browse code

Catch sigwinch client

Guillaume J. Charmes authored on 2013/05/25 03:07:32
Showing 1 changed files
... ...
@@ -15,10 +15,12 @@ import (
15 15
 	"net/http/httputil"
16 16
 	"net/url"
17 17
 	"os"
18
+	"os/signal"
18 19
 	"path/filepath"
19 20
 	"reflect"
20 21
 	"strconv"
21 22
 	"strings"
23
+	"syscall"
22 24
 	"text/tabwriter"
23 25
 	"time"
24 26
 	"unicode"
... ...
@@ -33,6 +35,19 @@ var (
33 33
 func ParseCommands(args ...string) error {
34 34
 	cli := NewDockerCli("0.0.0.0", 4243)
35 35
 
36
+	c := make(chan os.Signal, 1)
37
+	signal.Notify(c, syscall.SIGWINCH)
38
+	go func() {
39
+		for sig := range c {
40
+			if sig == syscall.SIGWINCH {
41
+				_, _, err := cli.call("GET", "/auth", nil)
42
+				if err != nil {
43
+					utils.Debugf("Error resize: %s", err)
44
+				}
45
+			}
46
+		}
47
+	}()
48
+
36 49
 	if len(args) > 0 {
37 50
 		methodName := "Cmd" + strings.ToUpper(args[0][:1]) + strings.ToLower(args[0][1:])
38 51
 		method, exists := reflect.TypeOf(cli).MethodByName(methodName)
... ...
@@ -1294,6 +1309,6 @@ func NewDockerCli(host string, port int) *DockerCli {
1294 1294
 }
1295 1295
 
1296 1296
 type DockerCli struct {
1297
-	host       string
1298
-	port       int
1297
+	host string
1298
+	port int
1299 1299
 }