elvish/sys/tc.go
Xuan Chen cf12ae3060 Rewrite sys/ package in pure Go (#345)
* Re-implemented in pure golang.

Signed-off-by: xchenan <xchenan@gmail.com>

* Vendored github.com/mattn/go-isatty/ and golang.org/x/sys/unix/; Fixed issues on MacOS

Signed-off-by: xchenan <xchenan@gmail.com>

* Added comments in winsize.go; Removed unused functions and constants in termios_linux.go and termios_bsd.go;

Signed-off-by: xchenan <xchenan@gmail.com>

* Handled distinctive NFDBits and func index's return values according to
different architectures.

Signed-off-by: xchenan <xchenan@gmail.com>
2017-05-23 20:24:04 +01:00

26 lines
501 B
Go

package sys
import (
"syscall"
"unsafe"
)
func Tcgetpgrp(fd int) (int, error) {
var pid int
_, _, errno := syscall.RawSyscall(syscall.SYS_IOCTL, uintptr(fd),
uintptr(syscall.TIOCGPGRP), uintptr(unsafe.Pointer(&pid)))
if errno == 0 {
return pid, nil
}
return -1, errno
}
func Tcsetpgrp(fd int, pid int) error {
_, _, errno := syscall.RawSyscall(syscall.SYS_IOCTL, uintptr(fd),
uintptr(syscall.TIOCSPGRP), uintptr(unsafe.Pointer(&pid)))
if errno == 0 {
return nil
}
return errno
}