Path: blob/main/vendor/github.com/chzyer/readline/term_linux.go
2875 views
// Copyright 2013 The Go Authors. All rights reserved.1// Use of this source code is governed by a BSD-style2// license that can be found in the LICENSE file.34package readline56import (7"syscall"8"unsafe"9)1011// These constants are declared here, rather than importing12// them from the syscall package as some syscall packages, even13// on linux, for example gccgo, do not declare them.14const ioctlReadTermios = 0x5401 // syscall.TCGETS15const ioctlWriteTermios = 0x5402 // syscall.TCSETS1617func getTermios(fd int) (*Termios, error) {18termios := new(Termios)19_, _, err := syscall.Syscall6(syscall.SYS_IOCTL, uintptr(fd), ioctlReadTermios, uintptr(unsafe.Pointer(termios)), 0, 0, 0)20if err != 0 {21return nil, err22}23return termios, nil24}2526func setTermios(fd int, termios *Termios) error {27_, _, err := syscall.Syscall6(syscall.SYS_IOCTL, uintptr(fd), ioctlWriteTermios, uintptr(unsafe.Pointer(termios)), 0, 0, 0)28if err != 0 {29return err30}31return nil32}333435