Remove some OS from .goxc.json file

This commit is contained in:
Quentin Perez 2015-11-19 00:15:13 +01:00
parent cbfcf7b358
commit 2effb888f5
4 changed files with 59 additions and 18 deletions

View File

@ -1,6 +1,7 @@
{
"AppName": "gotty-client",
"ArtifactsDest": "dist",
"BuildConstraints": "!plan9,!nacl,!solaris",
"OutPath": "{{.Dest}}{{.PS}}{{.Version}}{{.PS}}{{.ExeName}}_{{.Version}}_{{.Os}}_{{.Arch}}{{.Ext}}",
"TasksExclude": [
"go-test",

34
arch.go Normal file
View File

@ -0,0 +1,34 @@
// +build !windows
package gottyclient
import (
"encoding/json"
"fmt"
"os"
"os/signal"
"syscall"
"unsafe"
)
func notifySignalSIGWINCH(c chan<- os.Signal) {
signal.Notify(c, syscall.SIGWINCH)
}
func resetSignalSIGWINCH() {
signal.Reset(syscall.SIGWINCH)
}
func syscallTIOCGWINSZ() ([]byte, error) {
ws := winsize{}
syscall.Syscall(syscall.SYS_IOCTL,
uintptr(0), uintptr(syscall.TIOCGWINSZ),
uintptr(unsafe.Pointer(&ws)))
b, err := json.Marshal(ws)
if err != nil {
return nil, fmt.Errorf("json.Marshal error: %v", err)
}
return b, err
}

16
arch_windows.go Normal file
View File

@ -0,0 +1,16 @@
package gottyclient
import (
"errors"
"os"
)
func notifySignalSIGWINCH(c chan<- os.Signal) {
}
func resetSignalSIGWINCH() {
}
func syscallTIOCGWINSZ() ([]byte, error) {
return nil, errors.New("SIGWINCH isn't supported on this ARCH")
}

View File

@ -9,13 +9,10 @@ import (
"net/http"
"net/url"
"os"
"os/signal"
"regexp"
"strings"
"sync"
"syscall"
"time"
"unsafe"
"github.com/moul/gotty-client/vendor/github.com/Sirupsen/logrus"
"github.com/moul/gotty-client/vendor/github.com/creack/goselect"
@ -243,24 +240,17 @@ type winsize struct {
func (c *Client) termsizeLoop(wg *sync.WaitGroup) {
defer wg.Done()
ch := make(chan os.Signal, 1)
signal.Notify(ch, syscall.SIGWINCH)
defer signal.Reset(syscall.SIGWINCH)
ws := winsize{}
notifySignalSIGWINCH(ch)
defer resetSignalSIGWINCH()
for {
syscall.Syscall(syscall.SYS_IOCTL,
uintptr(0), uintptr(syscall.TIOCGWINSZ),
uintptr(unsafe.Pointer(&ws)))
b, err := json.Marshal(ws)
if err != nil {
logrus.Warnf("json.Marshal error: %v", err)
}
err = c.write(append([]byte("2"), b...))
if err != nil {
if b, err := syscallTIOCGWINSZ(); err != nil {
logrus.Warn(err)
} else {
if err = c.write(append([]byte("2"), b...)); err != nil {
logrus.Warnf("ws.WriteMessage failed: %v", err)
}
}
select {
case <-c.QuitChan:
return