Skip to content

Commit 4e6bee8

Browse files
authored
Merge pull request #299 from priyawadhwa/ioctl
Use unix.IoctlSetTermios instead of ioctl system call on darwin
2 parents d64481a + 7c4e0ec commit 4e6bee8

File tree

3 files changed

+10
-11
lines changed

3 files changed

+10
-11
lines changed

go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,5 +5,5 @@ go 1.14
55
require (
66
github.com/mitchellh/go-ps v1.0.0
77
github.com/stretchr/testify v1.6.1
8-
golang.org/x/sys v0.0.0-20200722175500-76b94024e4b6
8+
golang.org/x/sys v0.0.0-20201015000850-e3ed0017c211
99
)

go.sum

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@ github.com/stretchr/testify v1.6.1 h1:hDPOHmpOpP40lSULcqw7IrRb/u7w6RpDC9399XyoNd
99
github.com/stretchr/testify v1.6.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
1010
golang.org/x/sys v0.0.0-20200722175500-76b94024e4b6 h1:X9xIZ1YU8bLZA3l6gqDUHSFiD0GFI9S548h6C8nDtOY=
1111
golang.org/x/sys v0.0.0-20200722175500-76b94024e4b6/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
12+
golang.org/x/sys v0.0.0-20201015000850-e3ed0017c211 h1:9UQO31fZ+0aKQOFldThf7BKPMJTiBfWycGh/u3UoO88=
13+
golang.org/x/sys v0.0.0-20201015000850-e3ed0017c211/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
1214
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
1315
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c h1:dUUwHk2QECo/6vqA44rthZ8ie2QXMNeKRTHCNY2nXvo=
1416
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=

go/pty_util_darwin.go

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -7,26 +7,23 @@ which is under Apache License Version 2.0, January 2004
77
*/
88
import (
99
"os"
10-
"unsafe"
1110

1211
"golang.org/x/sys/unix"
1312
)
1413

1514
func tcget(fd uintptr, p *unix.Termios) error {
16-
return ioctl(fd, unix.TIOCGETA, uintptr(unsafe.Pointer(p)))
17-
}
18-
19-
func tcset(fd uintptr, p *unix.Termios) error {
20-
return ioctl(fd, unix.TIOCSETA, uintptr(unsafe.Pointer(p)))
21-
}
22-
23-
func ioctl(fd, flag, data uintptr) error {
24-
if _, _, err := unix.Syscall(unix.SYS_IOCTL, fd, flag, data); err != 0 {
15+
termios, err := unix.IoctlGetTermios(int(fd), unix.TIOCGETA)
16+
if err != nil {
2517
return err
2618
}
19+
*p = *termios
2720
return nil
2821
}
2922

23+
func tcset(fd uintptr, p *unix.Termios) error {
24+
return unix.IoctlSetTermios(int(fd), unix.TIOCSETA, p)
25+
}
26+
3027
func saneTerminal(f *os.File) error {
3128
// Go doesn't have a wrapper for any of the termios ioctls.
3229
var termios unix.Termios

0 commit comments

Comments
 (0)