mirror of
https://github.com/go-sylixos/elvish.git
synced 2024-12-14 11:17:52 +08:00
cf12ae3060
* 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>
26 lines
501 B
Go
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
|
|
}
|