mirror of
https://github.com/creack/pty.git
synced 2026-03-31 18:47:10 +09:00
add openbsd/amd64 support (#58)
* add openbsd/amd64 support * Remove extra C dependency and add time include Signed-off-by: Guillaume J. Charmes <gcharmes@magicleap.com>
This commit is contained in:
committed by
GitHub
parent
1278f20d9c
commit
f8811ff0e5
@@ -13,7 +13,7 @@ GODEFS="go tool cgo -godefs"
|
||||
$GODEFS types.go |gofmt > ztypes_$GOARCH.go
|
||||
|
||||
case $GOOS in
|
||||
freebsd|dragonfly)
|
||||
freebsd|dragonfly|openbsd)
|
||||
$GODEFS types_$GOOS.go |gofmt > ztypes_$GOOSARCH.go
|
||||
;;
|
||||
esac
|
||||
|
||||
33
pty_openbsd.go
Normal file
33
pty_openbsd.go
Normal file
@@ -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
|
||||
}
|
||||
@@ -1,4 +1,4 @@
|
||||
// +build !linux,!darwin,!freebsd,!dragonfly
|
||||
// +build !linux,!darwin,!freebsd,!dragonfly,!openbsd
|
||||
|
||||
package pty
|
||||
|
||||
|
||||
14
types_openbsd.go
Normal file
14
types_openbsd.go
Normal file
@@ -0,0 +1,14 @@
|
||||
// +build ignore
|
||||
|
||||
package pty
|
||||
|
||||
/*
|
||||
#include <sys/time.h>
|
||||
#include <stdlib.h>
|
||||
#include <sys/tty.h>
|
||||
*/
|
||||
import "C"
|
||||
|
||||
type ptmget C.struct_ptmget
|
||||
|
||||
var ioctl_PTMGET = C.PTMGET
|
||||
13
ztypes_openbsd_amd64.go
Normal file
13
ztypes_openbsd_amd64.go
Normal file
@@ -0,0 +1,13 @@
|
||||
// Created by cgo -godefs - DO NOT EDIT
|
||||
// cgo -godefs types_openbsd.go
|
||||
|
||||
package pty
|
||||
|
||||
type ptmget struct {
|
||||
Cfd int32
|
||||
Sfd int32
|
||||
Cn [16]int8
|
||||
Sn [16]int8
|
||||
}
|
||||
|
||||
var ioctl_PTMGET = 0x40287401
|
||||
Reference in New Issue
Block a user