summaryrefslogtreecommitdiffstats
path: root/vendor/github.com/jesseduffield/pty/pty_openbsd.go
diff options
context:
space:
mode:
authorJesse Duffield <jessedduffield@gmail.com>2018-12-18 21:25:28 +1100
committerJesse Duffield <jessedduffield@gmail.com>2018-12-18 21:25:28 +1100
commit319064f040e028d75480ac0093225f23e81ec635 (patch)
tree73ffd64936956c69ad3b13389c4580b0af1fa7ff /vendor/github.com/jesseduffield/pty/pty_openbsd.go
parentf5f726e9c46450fee60330c1c453d33d1566e106 (diff)
switch to our own fork of pty which lets us set our own stdout and stderr
Diffstat (limited to 'vendor/github.com/jesseduffield/pty/pty_openbsd.go')
-rw-r--r--vendor/github.com/jesseduffield/pty/pty_openbsd.go33
1 files changed, 33 insertions, 0 deletions
diff --git a/vendor/github.com/jesseduffield/pty/pty_openbsd.go b/vendor/github.com/jesseduffield/pty/pty_openbsd.go
new file mode 100644
index 000000000..6e7aeae7c
--- /dev/null
+++ b/vendor/github.com/jesseduffield/pty/pty_openbsd.go
@@ -0,0 +1,33 @@
+package pty
+
+import (
+ "os"
+ "syscall"
+ "unsafe"
+)
+
+func open() (pty, tty *os.File, err error) {
+ /*
+ * from ptm(4):
+ * The PTMGET command allocates a free pseudo terminal, changes its
+ * ownership to the caller, revokes the access privileges for all previous
+ * users, opens the file descriptors for the master and slave devices and
+ * returns them to the caller in struct ptmget.
+ */
+
+ p, err := os.OpenFile("/dev/ptm", os.O_RDWR|syscall.O_CLOEXEC, 0)
+ if err != nil {
+ return nil, nil, err
+ }
+ defer p.Close()
+
+ var ptm ptmget
+ if err := ioctl(p.Fd(), uintptr(ioctl_PTMGET), uintptr(unsafe.Pointer(&ptm))); err != nil {
+ return nil, nil, err
+ }
+
+ pty = os.NewFile(uintptr(ptm.Cfd), "/dev/ptm")
+ tty = os.NewFile(uintptr(ptm.Sfd), "/dev/ptm")
+
+ return pty, tty, nil
+}