File: ioctl_posix.go

package info (click to toggle)
golang-github-hinshun-vt10x 0.0~git20220301.5011da4-1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, forky, sid, trixie
  • size: 152 kB
  • sloc: makefile: 2
file content (31 lines) | stat: -rw-r--r-- 592 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
// +build linux darwin dragonfly solaris openbsd netbsd freebsd

package vt10x

import (
	"os"
	"syscall"
	"unsafe"
)

func ioctl(f *os.File, cmd, p uintptr) error {
	_, _, errno := syscall.Syscall(
		syscall.SYS_IOCTL,
		f.Fd(),
		syscall.TIOCSWINSZ,
		p)
	if errno != 0 {
		return syscall.Errno(errno)
	}
	return nil
}

func ResizePty(pty *os.File, cols, rows int) error {
	var w struct{ row, col, xpix, ypix uint16 }
	w.row = uint16(rows)
	w.col = uint16(cols)
	w.xpix = 16 * uint16(cols)
	w.ypix = 16 * uint16(rows)
	return ioctl(pty, syscall.TIOCSWINSZ,
		uintptr(unsafe.Pointer(&w)))
}