tc_netbsd.go 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. /*
  2. Copyright The containerd Authors.
  3. Licensed under the Apache License, Version 2.0 (the "License");
  4. you may not use this file except in compliance with the License.
  5. You may obtain a copy of the License at
  6. http://www.apache.org/licenses/LICENSE-2.0
  7. Unless required by applicable law or agreed to in writing, software
  8. distributed under the License is distributed on an "AS IS" BASIS,
  9. WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  10. See the License for the specific language governing permissions and
  11. limitations under the License.
  12. */
  13. package console
  14. import (
  15. "bytes"
  16. "os"
  17. "golang.org/x/sys/unix"
  18. )
  19. const (
  20. cmdTcGet = unix.TIOCGETA
  21. cmdTcSet = unix.TIOCSETA
  22. )
  23. // unlockpt unlocks the slave pseudoterminal device corresponding to the master pseudoterminal referred to by f.
  24. // unlockpt should be called before opening the slave side of a pty.
  25. // This does not exist on NetBSD, it does not allocate controlling terminals on open
  26. func unlockpt(f *os.File) error {
  27. return nil
  28. }
  29. // ptsname retrieves the name of the first available pts for the given master.
  30. func ptsname(f *os.File) (string, error) {
  31. ptm, err := unix.IoctlGetPtmget(int(f.Fd()), unix.TIOCPTSNAME)
  32. if err != nil {
  33. return "", err
  34. }
  35. return string(ptm.Sn[:bytes.IndexByte(ptm.Sn[:], 0)]), nil
  36. }