pty_netbsd.go 580 B

12345678910111213141516171819202122232425262728293031
  1. package termios
  2. import (
  3. "bytes"
  4. "golang.org/x/sys/unix"
  5. )
  6. func open_pty_master() (uintptr, error) {
  7. fd, err := unix.Open("/dev/ptmx", unix.O_NOCTTY|unix.O_RDWR, 0666)
  8. if err != nil {
  9. return 0, err
  10. }
  11. return uintptr(fd), nil
  12. }
  13. func Ptsname(fd uintptr) (string, error) {
  14. ptm, err := unix.IoctlGetPtmget(int(fd), unix.TIOCPTSNAME)
  15. if err != nil {
  16. return "", err
  17. }
  18. return string(ptm.Sn[:bytes.IndexByte(ptm.Sn[:], 0)]), nil
  19. }
  20. func grantpt(fd uintptr) error {
  21. return unix.IoctlSetInt(int(fd), unix.TIOCGRANTPT, 0)
  22. }
  23. func unlockpt(fd uintptr) error {
  24. return nil
  25. }