github.com/ladydascalie/elvish@v0.0.0-20170703214355-2964dd3ece7f/sys/tc.go (about)

     1  package sys
     2  
     3  import (
     4  	"syscall"
     5  	"unsafe"
     6  )
     7  
     8  func Tcgetpgrp(fd int) (int, error) {
     9  	var pid int
    10  	_, _, errno := syscall.RawSyscall(syscall.SYS_IOCTL, uintptr(fd),
    11  		uintptr(syscall.TIOCGPGRP), uintptr(unsafe.Pointer(&pid)))
    12  	if errno == 0 {
    13  		return pid, nil
    14  	}
    15  	return -1, errno
    16  }
    17  
    18  func Tcsetpgrp(fd int, pid int) error {
    19  	_, _, errno := syscall.RawSyscall(syscall.SYS_IOCTL, uintptr(fd),
    20  		uintptr(syscall.TIOCSPGRP), uintptr(unsafe.Pointer(&pid)))
    21  	if errno == 0 {
    22  		return nil
    23  	}
    24  	return errno
    25  }