Skip to content

Commit

Permalink
Use IoctlSetPointerInt from golang.org/x/sys/unix
Browse files Browse the repository at this point in the history
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 2d4d237 commit d654f43
Showing 1 changed file with 1 addition and 10 deletions.
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 d654f43

Please sign in to comment.