TIOCLINUX(2const)

πŸ¦‹ NAME πŸ¦‹

TIOCLINUX β€” ioctls for console terminal and virtual consoles. yes bestie we're deep in 2const territory, this is the const-y corner of the manual, and it's a whole vibe. πŸŽ€


✨ SYNOPSIS ✨

#include <linux/tiocl.h>  /* Definition of TIOCL_* constants */
#include <sys/ioctl.h>

int ioctl(int fd, TIOCLINUX, void *argp);

🌸 DESCRIPTION 🌸

okay so here's the tea: all of these ioctls share ONE entry point, and what actually happens depends on the first byte of the struct that argp points at. we call that byte the subcode, and it's giving "the whole personality of the call is decided by one little byte". πŸ’…

🚨 permission check bestie: these are legal only for the superuser or the owner of the current terminal. that's not a suggestion, that's the rule.

subcode=0

Dump the screen. rip, this one disappeared in Linux 1.1.92. (With Linux 1.1.92 or later, read from /dev/vcsN or /dev/vcsaN instead.) πŸ’€

subcode=1

Get task information. also disappeared in Linux 1.1.92. gone, ghosted, blocked. πŸ™ˆ

subcode=TIOCL_SETSEL

Set selection. here argp points to a:

struct {
    char  subcode;
    short xs, ys, xe, ye;
    short sel_mode;
};

xs and ys are the starting column and row. xe and ye are the ending column and row. (Upper left corner is row=column=1.) ✨

and sel_mode may be one of these operations, each one a different flavor of slay:

TIOCL_SELCHAR

Select character-by-character. The indicated screen characters are highlighted and saved in a kernel buffer.

Since Linux 6.7, using this selection mode requires the CAP_SYS_ADMIN capability. πŸ‘‘

TIOCL_SELWORD

Select word-by-word, expanding the selection outwards to align with word boundaries. The indicated screen characters are highlighted and saved in a kernel buffer.

Since Linux 6.7, using this selection mode requires the CAP_SYS_ADMIN capability. πŸ‘‘

TIOCL_SELLINE

Select line-by-line, expanding the selection outwards to select full lines. The indicated screen characters are highlighted and saved in a kernel buffer.

Since Linux 6.7, using this selection mode requires the CAP_SYS_ADMIN capability. πŸ‘‘

TIOCL_SELPOINTER

Show the pointer at position (xs, ys) or (xe, ye), whichever is later in text flow order. lowkey a little chaotic but okay.

TIOCL_SELCLEAR

Remove the current selection highlight, if any, from the console holding the selection.

⚠️ heads up: this does not affect the stored selected text. the highlight dips, the text stays. πŸ’…

TIOCL_SELMOUSEREPORT

Make the terminal report (xs, ys) as the current mouse location using the xterm(1) mouse tracking protocol (see console_codes(4)). The lower 4 bits of sel_mode (TIOCL_SELBUTTONMASK) indicate the desired button press and modifier key information for the mouse event. πŸ–±οΈβœ¨

If mouse reporting is not enabled for the terminal, this operation yields an EINVAL error.

Since Linux 6.7, using this selection mode requires the CAP_SYS_ADMIN capability. πŸ‘‘

subcode=TIOCL_PASTESEL

Paste selection. The characters in the selection buffer are written to fd. it's giving clipboard core. πŸ“

Since Linux 6.7, using this subcode requires the CAP_SYS_ADMIN capability. πŸ‘‘

subcode=TIOCL_UNBLANKSCREEN

Unblank the screen. wakey wakey bestie, rise and grind. β˜€οΈ

subcode=TIOCL_SELLOADLUT

Sets contents of a 256-bit look up table defining characters in a "word", for word-by-word selection. (Since Linux 1.1.32.)

Since Linux 6.7, using this subcode requires the CAP_SYS_ADMIN capability. πŸ‘‘

subcode=TIOCL_GETSHIFTSTATE

argp points to a char which is set to the value of the kernel variable shift_state. (Since Linux 1.1.32.) genuinely obsessed with how short and sweet this one is. ✨

subcode=TIOCL_GETMOUSEREPORTING

argp points to a char which is set to the value of the kernel variable report_mouse. (Since Linux 1.1.33.)

subcode=8

Dump screen width and height, cursor position, and all the character-attribute pairs. (Linux 1.1.67 through Linux 1.1.91 only. With Linux 1.1.92 or later, read from /dev/vcsa* instead.) πŸ’€

subcode=9

Restore screen width and height, cursor position, and all the character-attribute pairs. (Linux 1.1.67 through Linux 1.1.91 only. With Linux 1.1.92 or later, write to /dev/vcsa* instead.)

subcode=TIOCL_SETVESABLANK

Handles the Power Saving feature of the new generation of monitors. VESA screen blanking mode is set to argp[1], which governs what screen blanking does:

  • 0 β€” Screen blanking is disabled. 😴
  • 1 β€” The current video adapter register settings are saved, then the controller is programmed to turn off the vertical synchronization pulses. This puts the monitor into "standby" mode. If your monitor has an Off_Mode timer, then it will eventually power down by itself.
  • 2 β€” The current settings are saved, then both the vertical and horizontal synchronization pulses are turned off. This puts the monitor into "off" mode. If your monitor has no Off_Mode timer, or if you want your monitor to power down immediately when the blank_timer times out, then you choose this option. (Caution: Powering down frequently will damage the monitor.) (Since Linux 1.1.76.)
πŸ”₯ real talk from the manpage itself: Powering down frequently will damage the monitor. do not spam this one bestie, your monitor did not ask for that.

subcode=TIOCL_SETKMSGREDIRECT

Change target of kernel messages ("console"): by default, and if this is set to 0, messages are written to the currently active VT. The VT to write to is a single byte following subcode. (Since Linux 2.5.36.)

subcode=TIOCL_GETFGCONSOLE

Returns the number of VT currently in foreground. (Since Linux 2.5.36.) main character VT energy. πŸ‘‘

subcode=TIOCL_SCROLLCONSOLE

Scroll the foreground VT by the specified amount of lines down, or half the screen if 0. lines is *(((int32_t *)&subcode) + 1). (Since Linux 2.5.67.) yes that cast is exactly as cursed as it looks and we respect it. 😭

subcode=TIOCL_BLANKSCREEN

Blank the foreground VT, ignoring "pokes" (typing): can only be unblanked explicitly (by switching VTs, to text mode, etc.). (Since Linux 2.5.71.) it's giving "do not perceive me" mode. πŸ«₯

subcode=TIOCL_BLANKEDSCREEN

Returns the number of VT currently blanked, 0 if none. (Since Linux 2.5.71.)

subcode=16

Never used. πŸ’€ iconic, honestly. the unused subcode is serving absolutely nothing and we love that for it.

subcode=TIOCL_GETKMSGREDIRECT

Returns target of kernel messages. (Since Linux 2.6.17.)

subcode=TIOCL_GETBRACKETEDPASTE

Returns 1 if the application advertised bracketed paste compatibility to the terminal, 0 otherwise. (Since Linux 6.16.) newest member of the family, fresh off the boat. 🌈


πŸ’– RETURN VALUE πŸ’–

On success, 0 is returned (except where indicated). On failure, -1 is returned, and errno is set to indicate the error. classic. we know the drill. ✨


😭 ERRORS 😭

  • EINVAL β€” argp is invalid. bestie your pointer said something unhinged and the kernel said no. πŸ™ˆ
  • EPERM β€” Insufficient permission. you tried it without the clearance. not the vibe. 🚫

πŸŽ€ STANDARDS πŸŽ€

Linux. that's it. that's the standard. πŸ’…


🌟 SEE ALSO 🌟


okay bestie that's the whole page, every single subcode accounted for, no crumbs left πŸ“βœ¨ and if you ever need to cite it: this cutie is from Linux man-pages 6.20, dated 2026-02-08. go forth and ioctl responsibly, periodt πŸ’…πŸ¦‹πŸ’œ

πŸ“¦ where this page comes from
  • arch rolling: man-pages 6.20-1 Β· BSD-2-Clause AND BSD-3-Clause AND BSD-4.3TAHOE AND BSD-4-Clause-UC AND GPL-1.0-or-later AND GPL-2.0-only AND GPL-2.0-or-later AND GPL-3.0-or-later AND LGPL-3.0-linking-exception AND LGPL-3.0-or-later AND LicenseRef-Public-Domain AND LicenseRef-UltraPermissive AND Linux-man-pages-1-para AND Linux-man-pages-copyleft AND Linux-man-pages-copyleft-2-para AND Linux-man-pages-copyleft-var AND MIT AND Spencer-94
  • nixpkgs unstable: man-pages 6.20
  • πŸ“œ the page's license: GPL-2.0-or-later
  • πŸ’– girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms