1TCSETATTR(3P) POSIX Programmer's Manual TCSETATTR(3P)
2
3
4
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
12 tcsetattr - set the parameters associated with the terminal
13
15 #include <termios.h>
16
17 int tcsetattr(int fildes, int optional_actions,
18 const struct termios *termios_p);
19
20
22 The tcsetattr() function shall set the parameters associated with the
23 terminal referred to by the open file descriptor fildes (an open file
24 descriptor associated with a terminal) from the termios structure ref‐
25 erenced by termios_p as follows:
26
27 * If optional_actions is TCSANOW, the change shall occur immediately.
28
29 * If optional_actions is TCSADRAIN, the change shall occur after all
30 output written to fildes is transmitted. This function should be
31 used when changing parameters that affect output.
32
33 * If optional_actions is TCSAFLUSH, the change shall occur after all
34 output written to fildes is transmitted, and all input so far
35 received but not read shall be discarded before the change is made.
36
37 If the output baud rate stored in the termios structure pointed to by
38 termios_p is the zero baud rate, B0, the modem control lines shall no
39 longer be asserted. Normally, this shall disconnect the line.
40
41 If the input baud rate stored in the termios structure pointed to by
42 termios_p is 0, the input baud rate given to the hardware is the same
43 as the output baud rate stored in the termios structure.
44
45 The tcsetattr() function shall return successfully if it was able to
46 perform any of the requested actions, even if some of the requested
47 actions could not be performed. It shall set all the attributes that
48 the implementation supports as requested and leave all the attributes
49 not supported by the implementation unchanged. If no part of the
50 request can be honored, it shall return -1 and set errno to [EINVAL].
51 If the input and output baud rates differ and are a combination that is
52 not supported, neither baud rate shall be changed. A subsequent call to
53 tcgetattr() shall return the actual state of the terminal device
54 (reflecting both the changes made and not made in the previous tcse‐
55 tattr() call). The tcsetattr() function shall not change the values
56 found in the termios structure under any circumstances.
57
58 The effect of tcsetattr() is undefined if the value of the termios
59 structure pointed to by termios_p was not derived from the result of a
60 call to tcgetattr() on fildes; an application should modify only fields
61 and flags defined by this volume of IEEE Std 1003.1-2001 between the
62 call to tcgetattr() and tcsetattr(), leaving all other fields and flags
63 unmodified.
64
65 No actions defined by this volume of IEEE Std 1003.1-2001, other than a
66 call to tcsetattr() or a close of the last file descriptor in the sys‐
67 tem associated with this terminal device, shall cause any of the termi‐
68 nal attributes defined by this volume of IEEE Std 1003.1-2001 to
69 change.
70
71 If tcsetattr() is called from a process which is a member of a back‐
72 ground process group on a fildes associated with its controlling termi‐
73 nal:
74
75 * If the calling process is blocking or ignoring SIGTTOU signals, the
76 operation completes normally and no signal is sent.
77
78 * Otherwise, a SIGTTOU signal shall be sent to the process group.
79
81 Upon successful completion, 0 shall be returned. Otherwise, -1 shall be
82 returned and errno set to indicate the error.
83
85 The tcsetattr() function shall fail if:
86
87 EBADF The fildes argument is not a valid file descriptor.
88
89 EINTR A signal interrupted tcsetattr().
90
91 EINVAL The optional_actions argument is not a supported value, or an
92 attempt was made to change an attribute represented in the
93 termios structure to an unsupported value.
94
95 ENOTTY The file associated with fildes is not a terminal.
96
97
98 The tcsetattr() function may fail if:
99
100 EIO The process group of the writing process is orphaned, and the
101 writing process is not ignoring or blocking SIGTTOU.
102
103
104 The following sections are informative.
105
107 None.
108
110 If trying to change baud rates, applications should call tcsetattr()
111 then call tcgetattr() in order to determine what baud rates were actu‐
112 ally selected.
113
115 The tcsetattr() function can be interrupted in the following situa‐
116 tions:
117
118 * It is interrupted while waiting for output to drain.
119
120 * It is called from a process in a background process group and SIGT‐
121 TOU is caught.
122
123 See also the RATIONALE section in tcgetattr().
124
126 Using an input baud rate of 0 to set the input rate equal to the output
127 rate may not necessarily be supported in a future version of this vol‐
128 ume of IEEE Std 1003.1-2001.
129
131 cfgetispeed(), tcgetattr(), the Base Definitions volume of
132 IEEE Std 1003.1-2001, Chapter 11, General Terminal Interface,
133 <termios.h>, <unistd.h>
134
136 Portions of this text are reprinted and reproduced in electronic form
137 from IEEE Std 1003.1, 2003 Edition, Standard for Information Technology
138 -- Portable Operating System Interface (POSIX), The Open Group Base
139 Specifications Issue 6, Copyright (C) 2001-2003 by the Institute of
140 Electrical and Electronics Engineers, Inc and The Open Group. In the
141 event of any discrepancy between this version and the original IEEE and
142 The Open Group Standard, the original IEEE and The Open Group Standard
143 is the referee document. The original Standard can be obtained online
144 at http://www.opengroup.org/unix/online.html .
145
146
147
148IEEE/The Open Group 2003 TCSETATTR(3P)