TIOCSWINSZ(2const)
β¨ TIOCGWINSZ, TIOCSWINSZ β¨
okay bestie so you found yourself in the TIOCSWINSZ section of the 2const manual, and honestly? it's giving window resize energy π
this is the get-and-set-window-size duo.
π«Ά LIBRARY
Standard C library (libc, -lc) β the classic, the icon, no cap.
πΈ SYNOPSIS
#include <asm/termbits.h> /* Definition of TIOC*WINSZ constants */
#include <sys/ioctl.h>
int ioctl(int fd, TIOCGWINSZ, struct winsize *argp);
int ioctl(int fd, TIOCSWINSZ, const struct winsize *argp);
#include <asm/termios.h>
struct winsize {
unsigned short ws_row;
unsigned short ws_col;
unsigned short ws_xpixel; /* unused */
unsigned short ws_ypixel; /* unused */
};
so you're calling ioctl() with one of two constants and handing it a pointer to a struct winsize. TIOCGWINSZ gets, TIOCSWINSZ sets. and yeah, the header for the constants is asm/termbits.h, but the struct lives over in asm/termios.h, so you need both. annoying? yes. iconic? also yes π
π DESCRIPTION
The window sizes are kept in the kernel, but β plot twist β the kernel doesn't actually use them. lowkey the kernel is just holding them for you like a supportive bestie holding your bag π
exception: virtual consoles. In that one case, the kernel will update the window size when the size of the virtual console changes β for example, by loading a new font. so if fonts are your thing, this matters, otherwise it's vibes only.
TIOCGWINSZ Goal: get window size. π
TIOCSWINSZ Goal: set window size. βοΈ
and when the window size changes, a SIGWINCH signal gets sent to the foreground process group. that's right, your terminal is literally sending a signal, main character behavior, it just wants to tell you the shape of things changed π₯
β RETURN VALUE
On success, 0 is returned. On error, -1 is returned, and errno is set to indicate the error. so check your errno, bestie, it's not gonna text you first π
π SEE ALSO
ioctl(2)ioctl_tty(2const)
mwah, that's the whole page, no filler, no fluff, fr fr π¦ this came from Linux man-pages 6.20, dated 2026-02-08 β go off, go resize something, 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-1.0-or-later
- Copyright 2002, Walter Harms <walter.harms@informatik.uni-oldenburg.de>
- Copyright 2002, Andries E. Brouwer <aeb@cwi.nl>
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms