ioctl_tty(2)
โจ ioctl_tty โจ
okay bestie so this is ioctl_tty(2) โ the manual page for all the ioctls your terminal and your serial lines use ๐ it's a system call page, and yeah it's a lot, but we're gonna get through it together.
๐ NAME ๐
ioctl_tty โ the ioctls for terminals and serial lines. that's it, that's the whole vibe ๐ฆ
๐ LIBRARY ๐
Standard C library (libc, -lc) โ your usual ride-or-die. ๐
๐ธ SYNOPSIS ๐ธ
#include <asm/termbits.h> /* Definition of constants */
#include <sys/ioctl.h>
int ioctl(int fd, int op, ...);
no cap, those two headers are the whole entrance fee. asm/termbits.h is where the constants live, and sys/ioctl.h is where the actual ioctl() lives. ๐ซถ
๐ DESCRIPTION ๐
so ioctl(2) โ when you point it at a terminal or a serial port โ accepts a whole menu of possible operation arguments. not a small menu. a big one. like a Cheesecake Factory menu. ๐ญ
Most of them want a third argument, and the type varies, so this page calls it argp or arg. don't ask why there's two names, it's giving legacy, we love her anyway. ๐
โ ๏ธ real talk though: usingioctl()means your program is nonportable. fr fr. the POSIX interface described intermios(7)is the move whenever you can possibly swing it.ioctl()is the "I know what I'm doing and I accept the consequences" route. ๐
๐ Get and set terminal attributes ๐
the big ones. the main characters. ๐
TCGETS(2const)TCSETS(2const)TCSETSW(2const)TCSETSF(2const)TCGETS2(2const)TCSETS2(2const)TCSETSW2(2const)TCSETSF2(2const)TCGETA(2const)TCSETA(2const)TCSETAW(2const)TCSETAF(2const)
three little families, all doing the get-and-set terminal attributes thing. the 2 girlies are their own cluster, the A girlies are their own cluster, and the originals are just out here being iconic. ๐ฆ
๐ Locking the termios structure ๐
keeping that termios struct from being messed with behind your back. so protective, we stan. ๐
๐ช Get and set window size ๐ช
window size!! the thing every TUI is secretly screaming about. ๐
๐ฅ Sending a break ๐ฅ
break time. literally. sending a break. โจ (not a snack break, sadly. ๐)
๐ Software flow control ๐
just the one. she's solo and she's fine with it. ๐
๐ฆ Buffer count and flushing ๐ฆ
how much is sitting in there, and how to yeet it out. ๐ฅ
๐ Faking input ๐
it's giving "pretend the user typed this." dramatic. iconic. chaotic. ๐
๐ฅ๏ธ Redirecting console output ๐ฅ๏ธ
๐ง Controlling terminal ๐ง
grabbing the controlling tty, and then letting it go like a situationship. ๐ญ
๐ฏ Process group and session ID ๐ฏ
๐ซ Exclusive mode ๐ซ
get, set, unset. the full trio, no notes. ๐
๐ค๏ธ Line discipline ๐ค๏ธ
๐ Pseudoterminal ioctls ๐
the pty girlies!! lowkey the most fun group here. ๐ซถ
๐ Modem control ๐
yes we still do modems. heritage. history. respect. ๐
TIOCMGET(2const)TIOCMSET(2const)TIOCMBIC(2const)TIOCMBIS(2const)TIOCMIWAIT(2const)TIOCGICOUNT(2const)
๐ Marking a line as local ๐
๐ง Linux-specific ๐ง
for the TIOCLINUX(2const) ioctl, go look at ioctl_console(2) instead โ it lives over there, this page is not her home. ๐ก
๐ Kernel debugging ๐
๐ซ RETURN VALUE ๐ซ
- on success?
0is returned. slay. โจ - on error?
-1is returned, anderrnogets set to indicate the error. so always check thaterrno, bestie, it's telling you the tea. ๐ญ
๐ SEE ALSO ๐
that's the whole page ๐ you made it to the end, I'm so proud of you, actual main character energy.
this came from Linux man-pages 6.20, dated 2026-07-02 โ yeah she's from the future, we don't ask questions. ๐ฆโจ๐
๐ฆ 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
- Copyright 2002, Walter Harms <walter.harms@informatik.uni-oldenburg.de>
- Copyright 2002, Andries Brouwer <aeb@cwi.nl>
- ๐ girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms