pty_bsd.go 628 B

12345678910111213141516171819202122232425262728293031323334353637
  1. // +build dragonfly openbsd
  2. package termios
  3. // #include<stdlib.h>
  4. import "C"
  5. import "syscall"
  6. func open_pty_master() (uintptr, error) {
  7. rc := C.posix_openpt(syscall.O_NOCTTY | syscall.O_RDWR)
  8. if rc < 0 {
  9. return 0, syscall.Errno(rc)
  10. }
  11. return uintptr(rc), nil
  12. }
  13. func Ptsname(fd uintptr) (string, error) {
  14. slavename := C.GoString(C.ptsname(C.int(fd)))
  15. return slavename, nil
  16. }
  17. func grantpt(fd uintptr) error {
  18. rc := C.grantpt(C.int(fd))
  19. if rc == 0 {
  20. return nil
  21. }
  22. return syscall.Errno(rc)
  23. }
  24. func unlockpt(fd uintptr) error {
  25. rc := C.unlockpt(C.int(fd))
  26. if rc == 0 {
  27. return nil
  28. }
  29. return syscall.Errno(rc)
  30. }