Help us shape the future of Go! Take the 2026 Go Developer Survey

tty

package
v0.35.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 4, 2026 License: Apache-2.0 Imports: 5 Imported by: 0

Documentation

Overview

Package tty answers two questions about a file that may be a terminal: whether this process may touch it, and how big it is. It lives at the module root's internal/ so that both cmd/ and host/ may import it; Go's internal rule confines host/internal to the tree under host/.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ForegroundProcessGroup

func ForegroundProcessGroup(fd int) (int, error)

ForegroundProcessGroup returns the foreground process group of the terminal on fd.

The 32-bit read, not IoctlGetInt: the kernel writes a 4-byte pid_t, and IoctlGetInt reads into a Go int. s390x is big-endian and a release architecture, and there the value would land in the high half of that int — so the comparison in Owned could never succeed and upterm would decide it never owns its terminal.

func Owned

func Owned(f *os.File) bool

Owned reports whether f is a terminal this process is in the foreground of.

Reading or reconfiguring a terminal we are not in the foreground of is what SIGTTIN and SIGTTOU exist to prevent, and since a host ignores both, nothing else would stop it: `upterm host … &` would put the foreground shell's terminal into raw mode and then race it for input.

func Size

func Size(f *os.File) (termsize.Size, error)

Size reports f's geometry. It fails for anything that is not a terminal.

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL