tc_freebsd.go 708 B

123456789101112131415161718192021222324252627282930
  1. package console
  2. import (
  3. "fmt"
  4. "os"
  5. "golang.org/x/sys/unix"
  6. )
  7. const (
  8. cmdTcGet = unix.TIOCGETA
  9. cmdTcSet = unix.TIOCSETA
  10. )
  11. // unlockpt unlocks the slave pseudoterminal device corresponding to the master pseudoterminal referred to by f.
  12. // unlockpt should be called before opening the slave side of a pty.
  13. // This does not exist on FreeBSD, it does not allocate controlling terminals on open
  14. func unlockpt(f *os.File) error {
  15. return nil
  16. }
  17. // ptsname retrieves the name of the first available pts for the given master.
  18. func ptsname(f *os.File) (string, error) {
  19. n, err := unix.IoctlGetInt(int(f.Fd()), unix.TIOCGPTN)
  20. if err != nil {
  21. return "", err
  22. }
  23. return fmt.Sprintf("/dev/pts/%d", n), nil
  24. }