| 1 |
package pty |
| 2 |
|
| 3 |
import ( |
| 4 |
"os" |
| 5 |
"strconv" |
| 6 |
"syscall" |
| 7 |
"unsafe" |
| 8 |
) |
| 9 |
|
| 10 |
func ptyName(f *os.File) (string, error) { |
| 11 |
var out uint32 |
| 12 |
err := ioctl(f, "TIOCGPTN", syscall.TIOCGPTN, uintptr(unsafe.Pointer(&out))) |
| 13 |
if err != nil { |
| 14 |
return "", err |
| 15 |
} |
| 16 |
return "/dev/pts/" + strconv.Itoa(int(out)), nil |
| 17 |
} |
| 18 |
|
| 19 |
func ptyGrant(f *os.File) error { |
| 20 |
return nil |
| 21 |
} |
| 22 |
|
| 23 |
func ptyUnlock(f *os.File) error { |
| 24 |
var zero int |
| 25 |
return ioctl(f, "TIOCSPTLCK", syscall.TIOCSPTLCK, uintptr(unsafe.Pointer(&zero))) |
| 26 |
} |