|
| 1 | +// +build freebsd,!cgo |
| 2 | + |
| 3 | +/* |
| 4 | + Copyright The containerd Authors. |
| 5 | +
|
| 6 | + Licensed under the Apache License, Version 2.0 (the "License"); |
| 7 | + you may not use this file except in compliance with the License. |
| 8 | + You may obtain a copy of the License at |
| 9 | +
|
| 10 | + http://www.apache.org/licenses/LICENSE-2.0 |
| 11 | +
|
| 12 | + Unless required by applicable law or agreed to in writing, software |
| 13 | + distributed under the License is distributed on an "AS IS" BASIS, |
| 14 | + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 15 | + See the License for the specific language governing permissions and |
| 16 | + limitations under the License. |
| 17 | +*/ |
| 18 | + |
| 19 | +package console |
| 20 | + |
| 21 | +import ( |
| 22 | + "fmt" |
| 23 | + "os" |
| 24 | + |
| 25 | + "golang.org/x/sys/unix" |
| 26 | +) |
| 27 | + |
| 28 | +const ( |
| 29 | + cmdTcGet = unix.TIOCGETA |
| 30 | + cmdTcSet = unix.TIOCSETA |
| 31 | +) |
| 32 | + |
| 33 | +// |
| 34 | +// Implementing the functions below requires cgo support. Non-cgo stubs |
| 35 | +// versions are defined below to enable cross-compilation of source code |
| 36 | +// that depends on these functions, but the resultant cross-compiled |
| 37 | +// binaries cannot actually be used. If the stub function(s) below are |
| 38 | +// actually invoked they will display an error message and cause the |
| 39 | +// calling process to exit. |
| 40 | +// |
| 41 | + |
| 42 | +// unlockpt unlocks the slave pseudoterminal device corresponding to the master pseudoterminal referred to by f. |
| 43 | +// unlockpt should be called before opening the slave side of a pty. |
| 44 | +func unlockpt(f *os.File) error { |
| 45 | + panic("unlockpt() support requires cgo.") |
| 46 | +} |
| 47 | + |
| 48 | +// ptsname retrieves the name of the first available pts for the given master. |
| 49 | +func ptsname(f *os.File) (string, error) { |
| 50 | + n, err := unix.IoctlGetInt(int(f.Fd()), unix.TIOCGPTN) |
| 51 | + if err != nil { |
| 52 | + return "", err |
| 53 | + } |
| 54 | + return fmt.Sprintf("/dev/pts/%d", n), nil |
| 55 | +} |
0 commit comments