kitty/tools/tty/tty_linux.go
Marcel van der Boom 0853019e59 tty: take the TCSETS ioctl numbers from x/sys/unix
The hard-coded 0x5402/0x5403/0x5404 are the x86 (generic) values. On
powerpc TCSETS, TCSETSW and TCSETSF are 0x802c7414..6, so Tcsetattr
failed with ENOTTY and every kitten that sets terminal modes exited
at once: on ppc64le the paste confirmation (kitten ask) only flickered
and the paste was dropped. x/sys/unix defines the right value per
architecture, as already used for TCGETS in Tcgetattr and for
TIOCSETA* in tty_bsd.go. Drop the rest of the constant block too:
copied from pkg/term, unused, and also x86-only.

Verified on ppc64le: kitten ask under script(1) failed with
"inappropriate ioctl for device" (strace: ioctl 0x5402 = -ENOTTY);
with this change the TCSETS ioctl succeeds and the prompt runs.
2026-11-03 11:03:09 +01:00

24 lines
535 B
Go

// License: GPLv3 Copyright: 2022, Kovid Goyal, <kovid at kovidgoyal.net>
package tty
import "golang.org/x/sys/unix"
func Tcgetattr(fd int, argp *unix.Termios) error {
return unix.IoctlSetTermios(fd, unix.TCGETS, argp)
}
func Tcsetattr(fd int, action uintptr, argp *unix.Termios) error {
var request uint
switch action {
case TCSANOW:
request = unix.TCSETS
case TCSADRAIN:
request = unix.TCSETSW
case TCSAFLUSH:
request = unix.TCSETSF
default:
return unix.EINVAL
}
return unix.IoctlSetTermios(fd, request, argp)
}