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: using ioctl() means your program is nonportable. fr fr. the POSIX interface described in termios(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. ๐ŸŒŸ

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. ๐Ÿ‘‘


๐Ÿ  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? 0 is returned. slay. โœจ
  • on error? -1 is returned, and errno gets set to indicate the error. so always check that errno, 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
  • ๐Ÿ’– girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms