TCGETATTR(3)               POSIX Programmer's Manual              TCGETATTR(3)



PPRROOLLOOGG
       This manual page is part of the POSIX Programmer's Manual.  The OS
       implementation of this interface may differ (consult the corresponding
       OS manual page for details of OS behavior), or the interface may not be
       implemented on OS.


NNAAMMEE
       tcgetattr -- get the parameters associated with the terminal

SSYYNNOOPPSSIISS
       #include <termios.h>

       int tcgetattr(int _f_i_l_d_e_s, struct termios *_t_e_r_m_i_o_s___p);

DDEESSCCRRIIPPTTIIOONN
       The _t_c_g_e_t_a_t_t_r() function shall get the parameters associated with the
       terminal referred to by _f_i_l_d_e_s and store them in the tteerrmmiiooss structure
       referenced by _t_e_r_m_i_o_s___p.  The _f_i_l_d_e_s argument is an open file
       descriptor associated with a terminal.

       The _t_e_r_m_i_o_s___p argument is a pointer to a tteerrmmiiooss structure.

       The _t_c_g_e_t_a_t_t_r() operation is allowed from any process.

       If the terminal device supports different input and output baud rates,
       the baud rates stored in the tteerrmmiiooss structure returned by _t_c_g_e_t_a_t_t_r()
       shall reflect the actual baud rates, even if they are equal. If
       differing baud rates are not supported, the rate returned as the output
       baud rate shall be the actual baud rate. If the terminal device does
       not support split baud rates, the input baud rate stored in the tteerrmmiiooss
       structure shall be the output rate (as one of the symbolic values).

RREETTUURRNN VVAALLUUEE
       Upon successful completion, 0 shall be returned. Otherwise, -1 shall be
       returned and _e_r_r_n_o set to indicate the error.

EERRRROORRSS
       The _t_c_g_e_t_a_t_t_r() function shall fail if:

       EEBBAADDFF  The _f_i_l_d_e_s argument is not a valid file descriptor.

       EENNOOTTTTYY The file associated with _f_i_l_d_e_s is not a terminal.

       _T_h_e _f_o_l_l_o_w_i_n_g _s_e_c_t_i_o_n_s _a_r_e _i_n_f_o_r_m_a_t_i_v_e_.

EEXXAAMMPPLLEESS
       None.

AAPPPPLLIICCAATTIIOONN UUSSAAGGEE
       None.

RRAATTIIOONNAALLEE
       Care must be taken when changing the terminal attributes. Applications
       should always do a _t_c_g_e_t_a_t_t_r(), save the tteerrmmiiooss structure values
       returned, and then do a _t_c_s_e_t_a_t_t_r(), changing only the necessary
       fields. The application should use the values saved from the
       _t_c_g_e_t_a_t_t_r() to reset the terminal state whenever it is done with the
       terminal.  This is necessary because terminal attributes apply to the
       underlying port and not to each individual open instance; that is, all
       processes that have used the terminal see the latest attribute changes.

       A program that uses these functions should be written to catch all
       signals and take other appropriate actions to ensure that when the
       program terminates, whether planned or not, the terminal device's state
       is restored to its original state.

       Existing practice dealing with error returns when only part of a
       request can be honored is based on calls to the _i_o_c_t_l() function. In
       historical BSD and System V implementations, the corresponding _i_o_c_t_l()
       returns zero if the requested actions were semantically correct, even
       if some of the requested changes could not be made. Many existing
       applications assume this behavior and would no longer work correctly if
       the return value were changed from zero to -1 in this case.

       Note that either specification has a problem. When zero is returned, it
       implies everything succeeded even if some of the changes were not made.
       When -1 is returned, it implies everything failed even though some of
       the changes were made.

       Applications that need all of the requested changes made to work
       properly should follow _t_c_s_e_t_a_t_t_r() with a call to _t_c_g_e_t_a_t_t_r() and
       compare the appropriate field values.

FFUUTTUURREE DDIIRREECCTTIIOONNSS
       None.

SSEEEE AALLSSOO
       _t_c_s_e_t_a_t_t_r()

       The Base Definitions volume of POSIX.1-2008, _C_h_a_p_t_e_r _1_1, _G_e_n_e_r_a_l
       _T_e_r_m_i_n_a_l _I_n_t_e_r_f_a_c_e, <<tteerrmmiiooss..hh>>

CCOOPPYYRRIIGGHHTT
       Portions of this text are reprinted and reproduced in electronic form
       from IEEE Std 1003.1, 2013 Edition, Standard for Information Technology
       -- Portable Operating System Interface (POSIX), The Open Group Base
       Specifications Issue 7, Copyright (C) 2013 by the Institute of
       Electrical and Electronics Engineers, Inc and The Open Group.  (This is
       POSIX.1-2008 with the 2013 Technical Corrigendum 1 applied.) In the
       event of any discrepancy between this version and the original IEEE and
       The Open Group Standard, the original IEEE and The Open Group Standard
       is the referee document. The original Standard can be obtained online
       at http://www.unix.org/online.html .

       Any typographical or formatting errors that appear in this page are
       most likely to have been introduced during the conversion of the source
       files to man page format. To report such errors, see
       https://www.kernel.org/doc/man-pages/reporting_bugs.html .



IEEE/The Open Group                  2013                         TCGETATTR(3)
