1TCGETATTR(3P)              POSIX Programmer's Manual             TCGETATTR(3P)
2
3
4

PROLOG

6       This  manual  page is part of the POSIX Programmer's Manual.  The Linux
7       implementation of this interface may differ (consult the  corresponding
8       Linux  manual page for details of Linux behavior), or the interface may
9       not be implemented on Linux.
10
11

NAME

13       tcgetattr — get the parameters associated with the terminal
14

SYNOPSIS

16       #include <termios.h>
17
18       int tcgetattr(int fildes, struct termios *termios_p);
19

DESCRIPTION

21       The tcgetattr() function shall get the parameters associated  with  the
22       terminal  referred to by fildes and store them in the termios structure
23       referenced by termios_p.  The fildes argument is an open file  descrip‐
24       tor associated with a terminal.
25
26       The termios_p argument is a pointer to a termios structure.
27
28       The tcgetattr() operation is allowed from any process.
29
30       If  the terminal device supports different input and output baud rates,
31       the baud rates stored in the termios structure returned by  tcgetattr()
32       shall reflect the actual baud rates, even if they are equal. If differ‐
33       ing baud rates are not supported, the rate returned as the output  baud
34       rate  shall  be  the  actual baud rate. If the terminal device does not
35       support split baud rates, the input baud rate  stored  in  the  termios
36       structure shall be the output rate (as one of the symbolic values).
37

RETURN VALUE

39       Upon successful completion, 0 shall be returned. Otherwise, −1 shall be
40       returned and errno set to indicate the error.
41

ERRORS

43       The tcgetattr() function shall fail if:
44
45       EBADF  The fildes argument is not a valid file descriptor.
46
47       ENOTTY The file associated with fildes is not a terminal.
48
49       The following sections are informative.
50

EXAMPLES

52       None.
53

APPLICATION USAGE

55       None.
56

RATIONALE

58       Care must be taken when changing the terminal attributes.  Applications
59       should  always  do  a  tcgetattr(),  save  the termios structure values
60       returned, and then  do  a  tcsetattr(),  changing  only  the  necessary
61       fields.  The  application  should  use  the values saved from the tcge‐
62       tattr() to reset the terminal state whenever it is done with the termi‐
63       nal.  This is necessary because terminal attributes apply to the under‐
64       lying port and not to each individual open instance; that is, all  pro‐
65       cesses that have used the terminal see the latest attribute changes.
66
67       A program that uses these functions should be written to catch all sig‐
68       nals and take other appropriate actions to ensure that when the program
69       terminates,  whether  planned  or  not,  the terminal device's state is
70       restored to its original state.
71
72       Existing practice dealing with  error  returns  when  only  part  of  a
73       request  can  be  honored is based on calls to the ioctl() function. In
74       historical BSD and System V implementations, the corresponding  ioctl()
75       returns  zero  if the requested actions were semantically correct, even
76       if some of the requested changes  could  not  be  made.  Many  existing
77       applications assume this behavior and would no longer work correctly if
78       the return value were changed from zero to −1 in this case.
79
80       Note that either specification has a problem. When zero is returned, it
81       implies everything succeeded even if some of the changes were not made.
82       When −1 is returned, it implies everything failed even though  some  of
83       the changes were made.
84
85       Applications  that need all of the requested changes made to work prop‐
86       erly should follow tcsetattr() with a call to tcgetattr()  and  compare
87       the appropriate field values.
88

FUTURE DIRECTIONS

90       None.
91

SEE ALSO

93       tcsetattr()
94
95       The Base Definitions volume of POSIX.1‐2008, Chapter 11, General Termi‐
96       nal Interface, <termios.h>
97
99       Portions of this text are reprinted and reproduced in  electronic  form
100       from IEEE Std 1003.1, 2013 Edition, Standard for Information Technology
101       -- Portable Operating System Interface (POSIX),  The  Open  Group  Base
102       Specifications Issue 7, Copyright (C) 2013 by the Institute of Electri‐
103       cal and Electronics Engineers,  Inc  and  The  Open  Group.   (This  is
104       POSIX.1-2008  with  the  2013  Technical Corrigendum 1 applied.) In the
105       event of any discrepancy between this version and the original IEEE and
106       The  Open Group Standard, the original IEEE and The Open Group Standard
107       is the referee document. The original Standard can be  obtained  online
108       at http://www.unix.org/online.html .
109
110       Any  typographical  or  formatting  errors that appear in this page are
111       most likely to have been introduced during the conversion of the source
112       files  to  man page format. To report such errors, see https://www.ker
113       nel.org/doc/man-pages/reporting_bugs.html .
114
115
116
117IEEE/The Open Group                  2013                        TCGETATTR(3P)
Impressum