tcsetattr(3)
โจ tcgetattr, tcsetattr โ get & set terminal attributes โจ
okay bestie, welcome to the tcsetattr(3) page, aka the part of libc that lets you โจrearrange the vibesโจ of your terminal. no cap. ๐
๐ LIBRARY
Standard C library (that's libc, link with -lc) ๐
๐ฆ SYNOPSIS
#include <termios.h>
int tcgetattr(int fd, struct termios *termios_p);
int tcsetattr(int fd, int optional_actions,
const struct termios *termios_p);
๐ DESCRIPTION
tcgetattr() โ the read girlie ๐ธ
tcgetattr() gets the parameters associated with the object referred by fd, and stores them in the termios structure referenced by termios_p. it's giving "let me see what you're working with."
lowkey important: this function may be invoked from a background process ๐ โ however, the terminal attributes may be subsequently changed by a foreground process. so like, you got the tea, but someone in the front row might spill it. ๐ซ
tcsetattr() โ the set girlie ๐
tcsetattr() sets the parameters associated with the terminal (unless support is required from the underlying hardware that is not available) from the termios structure referred to by termios_p. basically: request submitted, but if the hardware can't do it, bestie, it just can't. ๐
and optional_actions specifies when the changes take effect, which is the main character decision of this whole function:
TCSANOWโ the change occurs immediately. no waiting, no thoughts, just pure yolo energy. ๐TCSADRAINโ the change occurs after all output written tofdhas been transmitted. this option should be used when changing parameters that affect output. like, let the words finish leaving the group chat first. โจTCSAFLUSHโ the change occurs after all output written to the object referred byfdhas been transmitted, and all input that has been received but not read will be discarded before the change is made. so it waits for the outbox to send, then it clears the unread messages. ๐ญ iconic, honestly.
๐ RETURN VALUE
0โ on success. slay. ๐-1โ on failure, and it setserrnoto indicate the error. not slay. ๐
๐ง ATTRIBUTES
for an explanation of the terms used in this section, see attributes(7). (yes we're citing our sources, academic queen ๐)
- Interface:
tcgetattr(),tcsetattr()- Attribute: Thread safety
- Value: MT-Safe
periodt. โจ
โญ STANDARDS
POSIX.1-2008. ๐
๐ฐ๏ธ HISTORY
POSIX.1-2001. it's been around, and it's been serving. ๐
โ ๏ธ CAVEATS
okay this one is the important one, so listen up bestie, no skimming:
tcsetattr() returns success if any of the requested changes could be successfully carried out.
read that again. any. not all. so the function can come back looking all happy and successful while some of your changes lowkey ghosted you. ๐ญ therefore, when making multiple changes, it may be necessary to follow this call with a further call to tcgetattr() to check that all changes have been performed successfully. always double-check, queen โ trust but verify. ๐ซถ
๐ SEE ALSO
and that's the whole vibe check, babe. this page is from Linux man-pages 6.20, dated 2026-07-02, and it's the tcsetattr(3) moment. go forth and set your terminal attributes responsibly. 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-2.0-or-later
- Copyright 2006-2015, Michael Kerrisk <mtk.manpages@gmail.com>
- ๐ girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms