aboutsummaryrefslogtreecommitdiff
path: root/src/internal/testpty/pty.go
diff options
context:
space:
mode:
Diffstat (limited to 'src/internal/testpty/pty.go')
-rw-r--r--src/internal/testpty/pty.go36
1 files changed, 36 insertions, 0 deletions
diff --git a/src/internal/testpty/pty.go b/src/internal/testpty/pty.go
new file mode 100644
index 0000000000..88a47cf85f
--- /dev/null
+++ b/src/internal/testpty/pty.go
@@ -0,0 +1,36 @@
+// Copyright 2017 The Go Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style
+// license that can be found in the LICENSE file.
+
+//go:build ((aix || dragonfly || freebsd || (linux && !android) || netbsd || openbsd) && cgo) || darwin
+
+// Package testpty is a simple pseudo-terminal package for Unix systems,
+// implemented by calling C functions via cgo.
+package testpty
+
+import (
+ "fmt"
+ "os"
+ "syscall"
+)
+
+type PtyError struct {
+ FuncName string
+ ErrorString string
+ Errno syscall.Errno
+}
+
+func ptyError(name string, err error) *PtyError {
+ return &PtyError{name, err.Error(), err.(syscall.Errno)}
+}
+
+func (e *PtyError) Error() string {
+ return fmt.Sprintf("%s: %s", e.FuncName, e.ErrorString)
+}
+
+func (e *PtyError) Unwrap() error { return e.Errno }
+
+// Open returns a control pty and the name of the linked process tty.
+func Open() (pty *os.File, processTTY string, err error) {
+ return open()
+}