simply remove the broken darwin implementation

This commit is contained in:
Keith Rarick
2011-08-15 14:43:39 -07:00
parent 227762de52
commit 411b3baef3
2 changed files with 2 additions and 90 deletions

View File

@@ -2,8 +2,8 @@
Pty is a Go package for using unix pseudo-terminals.
(Note, the Darwin implementation doesn't work. If you
are interested in fixing it, I'd appreciate a patch!)
(Note, there is only a Linux implementation. I'd appreciate a patch
for other systems!)
## Install

View File

@@ -1,88 +0,0 @@
package pty
import (
"os"
"syscall"
"unsafe"
)
const (
sys_TIOCGPTN = 0x80045430
sys_TIOCSPTLCK = 0x40045431
)
// Opens a pty and its corresponding tty.
func Open() (pty, tty *os.File, err os.Error) {
p, err := os.OpenFile("/dev/ptmx", os.O_RDWR, 0)
if err != nil {
return nil, nil, err
}
sname, err := ptsname(p)
if err != nil {
return nil, nil, err
}
err = grantpt(p)
if err != nil {
return nil, nil, err
}
t, err := os.OpenFile(sname, os.O_RDWR, 0)
if err != nil {
return nil, nil, err
}
return p, t, nil
}
const (
ptdev1 = "pqrsPQRS"
ptdev2 = "0123456789abcdefghijklmnopqrstuv"
)
func ptsname(f *os.File) (string, os.Error) {
fi, err := f.Stat()
if err != nil {
return "", err
}
return "/dev/tty" + string([]byte{
ptdev1[minor(fi.Rdev)/32],
ptdev2[minor(fi.Rdev)%32],
}),nil
}
func grantpt(f *os.File) os.Error {
p, err := os.StartProcess("/bin/ptchown", []string{"/bin/ptchown"}, &os.ProcAttr{Files: []*os.File{f}})
if err != nil {
return err
}
w, err := p.Wait(0)
if err != nil {
return err
}
if w.Exited() && w.ExitStatus() == 0 {
return nil
}
return os.EACCES
}
func ioctl(fd int, cmd uint, data *int) os.Error {
_, _, e := syscall.Syscall(
syscall.SYS_IOCTL,
uintptr(fd),
uintptr(cmd),
uintptr(unsafe.Pointer(data)),
)
if e != 0 {
return os.ENOTTY
}
return nil
}
func minor(d uint64) int {
return int(d & 0xffffffff)
}