Skip to content

Commit

Permalink
Use IoctlSetPointerInt from golang.org/x/sys/unix
Browse files Browse the repository at this point in the history
Update the golang.org/x/sys/unix dependency and use unix.IoctlSetPointerInt
instead of manually implementing it. This fixes the build on darwin
where direct syscalls, i.e.  unix.Syscall(SYS_IOCTL, ...) are no longer
allowed and exported as of golang/sys@6fcdbc0
  • Loading branch information
tklauser committed Sep 16, 2020
1 parent a607003 commit 3e6019e
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 13 deletions.
2 changes: 1 addition & 1 deletion go.mod
Expand Up @@ -4,5 +4,5 @@ go 1.13

require (
github.com/pkg/errors v0.8.1
golang.org/x/sys v0.0.0-20191120155948-bd437916bb0e
golang.org/x/sys v0.0.0-20200916030750-2334cc1a136f
)
4 changes: 2 additions & 2 deletions go.sum
@@ -1,4 +1,4 @@
github.com/pkg/errors v0.8.1 h1:iURUrRGxPUNPdy5/HRSm+Yj6okJ6UtLINN0Q9M4+h3I=
github.com/pkg/errors v0.8.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
golang.org/x/sys v0.0.0-20191120155948-bd437916bb0e h1:N7DeIrjYszNmSW409R3frPPwglRwMkXSBzwVbkOjLLA=
golang.org/x/sys v0.0.0-20191120155948-bd437916bb0e/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20200916030750-2334cc1a136f h1:6Sc1XOXTulBN6imkqo6XoAXDEzoQ4/ro6xy7Vn8+rOM=
golang.org/x/sys v0.0.0-20200916030750-2334cc1a136f/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
11 changes: 1 addition & 10 deletions tc_darwin.go
Expand Up @@ -19,7 +19,6 @@ package console
import (
"fmt"
"os"
"unsafe"

"golang.org/x/sys/unix"
)
Expand All @@ -29,18 +28,10 @@ const (
cmdTcSet = unix.TIOCSETA
)

func ioctl(fd, flag, data uintptr) error {
if _, _, err := unix.Syscall(unix.SYS_IOCTL, fd, flag, data); err != 0 {
return err
}
return nil
}

// unlockpt unlocks the slave pseudoterminal device corresponding to the master pseudoterminal referred to by f.
// unlockpt should be called before opening the slave side of a pty.
func unlockpt(f *os.File) error {
var u int32
return ioctl(f.Fd(), unix.TIOCPTYUNLK, uintptr(unsafe.Pointer(&u)))
return unix.IoctlSetPointerInt(int(f.Fd()), unix.TIOCPTYUNLK, 0)
}

// ptsname retrieves the name of the first available pts for the given master.
Expand Down

0 comments on commit 3e6019e

Please sign in to comment.