ioctl_tty(2)

πŸ’… ioctl_tty β€” bestie edition πŸ’…

okay so this is page ioctl_tty from section 2 (System Calls Manual) of the Linux man-pages, and it's literally the master list of terminal/serial ioctls. buckle up πŸŽ€


✨ NAME ✨

ioctl_tty β€” ioctls for terminals and serial lines. that's it, that's the whole vibe. πŸ’–


πŸ“š LIBRARY πŸ“š

Standard C library (libc, -lc). the classic. the icon. 🫢


🌸 SYNOPSIS 🌸

#include <asm/termbits.h>  /* Definition of constants */
#include <sys/ioctl.h>

int ioctl(int fd, int op, ...);

πŸ¦‹ DESCRIPTION πŸ¦‹

so the ioctl(2) call, when you point it at terminals and serial ports, will accept a truly unhinged number of possible operation arguments. like, so many. the menu is huge.

Most of them want a third argument, and the type of that argument varies depending on which op you picked β€” this page calls it argp or arg because naming things is hard. πŸ’€

bestie, real talk: use of ioctl() makes for nonportable programs. Use the POSIX interface described in termios(7) whenever possible. not me being dramatic, that's just the truth of it. πŸ™ˆ

Get and set terminal attributes

the "get the settings / set the settings" crew. all of these have their own pages:

  • TCGETS(2const)
  • TCSETS(2const)
  • TCSETSW(2const)
  • TCSETSF(2const)

the twos, which are the same energy but different:

  • TCGETS2(2const)
  • TCSETS2(2const)
  • TCSETSW2(2const)
  • TCSETSF2(2const)

and the A-squad, the legacy little guys:

  • TCGETA(2const)
  • TCSETA(2const)
  • TCSETAW(2const)
  • TCSETAF(2const)

Locking the termios structure

keep your hands off my settings, periodt. πŸ”’

  • TIOCGLCKTRMIOS(2const)
  • TIOCSLCKTRMIOS(2const)

Get and set window size

because how big is the window, truly. πŸ“

  • TIOCGWINSZ(2const)
  • TIOCSWINSZ(2const)

Sending a break

sent a break, hope they text back. 😭

  • TCSBRK(2const)
  • TCSBRKP(2const)
  • TIOCSBRK(2const)
  • TIOCCBRK(2const)

Software flow control

  • TCXONC(2const)

Buffer count and flushing

how much is in the buffer, and also get rid of it. two completely different moods, both iconic.

  • FIONREAD(2const)
  • TIOCINQ(2const)
  • TIOCOUTQ(2const)
  • TCFLSH(2const)
  • TIOCSERGETLSR(2const)

Faking input

she's lying but make it syscall πŸ’…

  • TIOCSTI(2const)

Redirecting console output

  • TIOCCONS(2const)

Controlling terminal

who's your controlling terminal? main character energy only. πŸ‘‘

  • TIOCSCTTY(2const)
  • TIOCNOTTY(2const)

Process group and session ID

  • TIOCGPGRP(2const)
  • TIOCSPGRP(2const)
  • TIOCGSID(2const)

Exclusive mode

no sharing. none. it's giving only child. 🌟

  • TIOCEXCL(2const)
  • TIOCGEXCL(2const)
  • TIOCNXCL(2const)

Line discipline

  • TIOCGETD(2const)
  • TIOCSETD(2const)

Pseudoterminal ioctls

the pty girlies know ✨

  • TIOCPKT(2const)
  • TIOCGPKT(2const)
  • TIOCSPTLCK(2const)
  • TIOCGPTLCK(2const)
  • TIOCGPTPEER(2const)

Modem control

  • TIOCMGET(2const)
  • TIOCMSET(2const)
  • TIOCMBIC(2const)
  • TIOCMBIS(2const)
  • TIOCMIWAIT(2const)
  • TIOCGICOUNT(2const)

Marking a line as local

  • TIOCGSOFTCAR(2const)
  • TIOCSSOFTCAR(2const)

Linux-specific

For the TIOCLINUX(2const) ioctl, see ioctl_console(2). it lives over there, go say hi 🐧

Kernel debugging

  • TIOCTTYGSTRUCT(2const)

πŸŽ€ RETURN VALUE πŸŽ€

  • on glow-up (success): 0 is returned ✨
  • on flop (error): -1 is returned, and errno is set to indicate the error πŸ’€

🌈 SEE ALSO 🌈

ioctl(2), ldattach(8), ioctl_console(2), termios(7), pty(7)


and that's the whole page, bestie, no cap 🫢 this was Linux man-pages 6.20, dated 2026-07-02, and honestly? she ate. mwah πŸ’‹

πŸ“¦ 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-1.0-or-later
  • πŸ’– girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms