1 .\" Copyright (c) 1991, 1993
2 .\" The Regents of the University of California. All rights reserved.
4 .\" Redistribution and use in source and binary forms, with or without
5 .\" modification, are permitted provided that the following conditions
7 .\" 1. Redistributions of source code must retain the above copyright
8 .\" notice, this list of conditions and the following disclaimer.
9 .\" 2. Redistributions in binary form must reproduce the above copyright
10 .\" notice, this list of conditions and the following disclaimer in the
11 .\" documentation and/or other materials provided with the distribution.
12 .\" 3. Neither the name of the University nor the names of its contributors
13 .\" may be used to endorse or promote products derived from this software
14 .\" without specific prior written permission.
16 .\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
17 .\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
18 .\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
19 .\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
20 .\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
21 .\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
22 .\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
23 .\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
24 .\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
25 .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
28 .\" @(#)tcsetattr.3 8.3 (Berkeley) 1/2/94
29 .\" $FreeBSD: src/lib/libc/gen/tcsetattr.3,v 1.6.2.4 2002/12/29 16:35:34 schweikh Exp $
43 .Nd manipulating the termios structure
49 .Fn cfgetispeed "const struct termios *t"
51 .Fn cfsetispeed "struct termios *t" "speed_t speed"
53 .Fn cfgetospeed "const struct termios *t"
55 .Fn cfsetospeed "struct termios *t" "speed_t speed"
57 .Fn cfsetspeed "struct termios *t" "speed_t speed"
59 .Fn cfmakeraw "struct termios *t"
61 .Fn tcgetattr "int fd" "struct termios *t"
63 .Fn tcsetattr "int fd" "int action" "const struct termios *t"
70 functions are provided for getting and setting the termios structure.
79 functions are provided for getting and setting the baud rate values in
80 the termios structure.
81 The effects of the functions on the terminal as described below
82 do not become effective, nor are all errors detected, until the
85 Certain values for baud rates set in the termios structure and passed to
87 have special meanings.
88 These are discussed in the portion of the manual page that describes the
91 .Sh GETTING AND SETTING THE BAUD RATE
92 The input and output baud rates are found in the termios structure.
95 is typedef'd in the include file
97 The value of the integer corresponds directly to the baud rate being
98 represented, however, the following symbolic values are defined.
122 #define B115200 115200
123 #define B230400 230400
126 #endif /* __BSD_VISIBLE */
131 function returns the input baud rate in the termios structure referenced by
136 function sets the input baud rate in the termios structure referenced by
143 function returns the output baud rate in the termios structure referenced by
148 function sets the output baud rate in the termios structure referenced by
155 function sets both the input and output baud rate in the termios structure
161 Upon successful completion, the functions
167 Otherwise, a value of -1 is returned and the global variable
169 is set to indicate the error.
170 .Sh GETTING AND SETTING THE TERMIOS STATE
171 This section describes the functions that are used to control the general
173 Unless otherwise noted for a specific command, these functions are restricted
174 from use by background processes.
175 Attempts to perform these operations shall cause the process group to be sent
179 If the calling process is blocking or ignoring
181 signals, the process is allowed to perform the operation and the
185 In all the functions, although
187 is an open file descriptor, the functions affect the underlying terminal
188 file, not just the open file description associated with the particular
193 function sets the flags stored in the termios structure to a state disabling
194 all input and output processing, giving a
196 It should be noted that there is no function to reverse this effect.
197 This is because there are a variety of processing options that could be
198 re-enabled and the correct method is for an application to snapshot the
199 current terminal state using the function
201 setting raw mode with
205 and then using another
207 with the saved state to revert to the previous terminal state.
211 function copies the parameters associated with the terminal referenced
214 in the termios structure referenced by
216 This function is allowed from a background process, however, the terminal
217 attributes may be subsequently changed by a foreground process.
221 function sets the parameters associated with the terminal from the
222 termios structure referenced by
228 the following values, as specified in the include file
230 .Bl -tag -width ".Dv TCSADRAIN"
232 The change occurs immediately.
234 The change occurs after all output written to
236 has been transmitted to the terminal.
239 should be used when changing parameters that affect output.
241 The change occurs after all output written to
243 has been transmitted to the terminal.
244 Additionally, any input that has been received but not read is discarded.
250 value, the values of the
258 The 0 baud rate is used to terminate the connection.
259 If 0 is specified as the output speed to the function
261 modem control will no longer be asserted on the terminal, disconnecting
264 If zero is specified as the input speed to the function
266 the input baud rate will be set to the same value as that specified by
267 the output baud rate.
271 is unable to make any of the requested changes, it returns -1 and
274 Otherwise, it makes all of the requested changes it can.
275 If the specified input and output baud rates differ and are a combination
276 that is not supported, neither baud rate is changed.
278 Upon successful completion, the functions
284 return -1 and the global variable
286 is set to indicate the error, as follows:
295 was not a valid file descriptor.
299 function was interrupted by a signal.
305 function was not valid, or an attempt was made to change an attribute
306 represented in the termios structure to an unsupported value.
308 The file associated with the
328 functions are expected to be compliant with the
340 function are extensions to the