|
NAME | LIBRARY | SYNOPSIS | DESCRIPTION | RETURN VALUE | ATTRIBUTES | STANDARDS | HISTORY | CAVEATS | SEE ALSO | COLOPHON |
|
|
|
tcsetattr(3) Library Functions Manual tcsetattr(3)
tcgetattr, tcsetattr - get and set terminal attributes
Standard C library (libc, -lc)
#include <termios.h>
int tcgetattr(int fd, struct termios *termios_p);
int tcsetattr(int fd, int optional_actions,
const struct termios *termios_p);
tcgetattr() gets the parameters associated with the object
referred by fd, and stores them in the termios structure
referenced by termios_p. This function may be invoked from a
background process; however, the terminal attributes may be
subsequently changed by a foreground process.
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. optional_actions specifies when the changes take
effect:
TCSANOW
the change occurs immediately.
TCSADRAIN
the change occurs after all output written to fd has been
transmitted. This option should be used when changing
parameters that affect output.
TCSAFLUSH
the change occurs after all output written to the object
referred by fd has been transmitted, and all input that has
been received but not read will be discarded before the
change is made.
0 on success.
-1 on failure and set errno to indicate the error.
For an explanation of the terms used in this section, see
attributes(7).
┌──────────────────────────────────────┬───────────────┬─────────┐
│ Interface │ Attribute │ Value │
├──────────────────────────────────────┼───────────────┼─────────┤
│ tcgetattr(), tcsetattr() │ Thread safety │ MT-Safe │
└──────────────────────────────────────┴───────────────┴─────────┘
POSIX.1-2008.
POSIX.1-2001.
tcsetattr() returns success if any of the requested changes could
be successfully carried out. 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.
termios(3type), termios(7)
This page is part of the man-pages (Linux kernel and C library
user-space interface documentation) project. Information about
the project can be found at
⟨https://www.kernel.org/doc/man-pages/⟩. If you have a bug report
for this manual page, see
⟨https://git.kernel.org/pub/scm/docs/man-pages/man-pages.git/tree/CONTRIBUTING⟩.
This page was obtained from the tarball man-pages-6.19.tar.gz
fetched from
⟨https://mirrors.edge.kernel.org/pub/linux/docs/man-pages/⟩ on
2026-09-09. If you discover any rendering problems in this HTML
version of the page, or you believe there is a better or more up-
to-date source for the page, or you have corrections or
improvements to the information in this COLOPHON (which is not
part of the original manual page), send a mail to
man-pages@man7.org
Linux man-pages 6.19 2026-07-02 tcsetattr(3)
Pages that refer to this page: cfsetspeed(3), stdin(3), attributes(7), signal-safety(7), termios(7)