tc_solaris_cgo.go 713 B

123456789101112131415161718192021222324252627282930313233343536
  1. // +build solaris,cgo
  2. package console
  3. import (
  4. "os"
  5. "golang.org/x/sys/unix"
  6. )
  7. //#include <stdlib.h>
  8. import "C"
  9. const (
  10. cmdTcGet = unix.TCGETS
  11. cmdTcSet = unix.TCSETS
  12. )
  13. // ptsname retrieves the name of the first available pts for the given master.
  14. func ptsname(f *os.File) (string, error) {
  15. ptspath, err := C.ptsname(C.int(f.Fd()))
  16. if err != nil {
  17. return "", err
  18. }
  19. return C.GoString(ptspath), nil
  20. }
  21. // unlockpt unlocks the slave pseudoterminal device corresponding to the master pseudoterminal referred to by f.
  22. // unlockpt should be called before opening the slave side of a pty.
  23. func unlockpt(f *os.File) error {
  24. if _, err := C.grantpt(C.int(f.Fd())); err != nil {
  25. return err
  26. }
  27. return nil
  28. }