1 .\" $NetBSD: tcsetattr.3,v 1.13 2010/03/22 19:30:55 joerg Exp $
3 .\" Copyright (c) 1991, 1993
4 .\" The Regents of the University of California. All rights reserved.
6 .\" Redistribution and use in source and binary forms, with or without
7 .\" modification, are permitted provided that the following conditions
9 .\" 1. Redistributions of source code must retain the above copyright
10 .\" notice, this list of conditions and the following disclaimer.
11 .\" 2. Redistributions in binary form must reproduce the above copyright
12 .\" notice, this list of conditions and the following disclaimer in the
13 .\" documentation and/or other materials provided with the distribution.
14 .\" 3. Neither the name of the University nor the names of its contributors
15 .\" may be used to endorse or promote products derived from this software
16 .\" without specific prior written permission.
18 .\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
19 .\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
20 .\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
21 .\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
22 .\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
23 .\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
24 .\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
25 .\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
26 .\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
27 .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
30 .\" @(#)tcsetattr.3 8.3 (Berkeley) 1/2/94
44 .Nd manipulating the termios structure
50 .Fn cfgetispeed "const struct termios *t"
52 .Fn cfsetispeed "struct termios *t" "speed_t speed"
54 .Fn cfgetospeed "const struct termios *t"
56 .Fn cfsetospeed "struct termios *t" "speed_t speed"
58 .Fn cfsetspeed "struct termios *t" "speed_t speed"
60 .Fn cfmakeraw "struct termios *t"
62 .Fn tcgetattr "int fd" "struct termios *t"
64 .Fn tcsetattr "int fd" "int action" "const struct termios *t"
71 functions are provided for getting and setting the termios structure.
80 functions are provided for getting and setting the baud rate values in
81 the termios structure.
82 The effects of the functions on the terminal as described below
83 do not become effective, nor are all errors detected, until the
86 Certain values for baud rates set in the termios structure and passed to
88 have special meanings.
89 These are discussed in the portion of the manual page that describes the
92 .Sh GETTING AND SETTING THE BAUD RATE
93 The input and output baud rates are found in the termios structure.
96 is typdef'd in the include file
98 The value of the integer corresponds directly to the baud rate being
99 represented, however, the following symbolic values are defined.
117 #ifndef _POSIX_SOURCE
120 #endif /*_POSIX_SOURCE */
125 function returns the input baud rate in the termios structure referenced by
130 function sets the input baud rate in the termios structure referenced by
137 function returns the output baud rate in the termios structure referenced by
142 function sets the output baud rate in the termios structure referenced by
149 function sets both the input and output baud rate in the termios structure
155 Upon successful completion, the functions
161 Otherwise, a value of -1 is returned and the global variable
163 is set to indicate the error.
164 .Sh GETTING AND SETTING THE TERMIOS STATE
165 This section describes the functions that are used to control the general
167 Unless otherwise noted for a specific command, these functions are restricted
168 from use by background processes.
169 Attempts to perform these operations shall cause the process group to be sent
171 If the calling process is blocking or ignoring SIGTTOU signals, the process
172 is allowed to perform the operation and the SIGTTOU signal is not sent.
174 In all the functions, although
176 is an open file descriptor, the functions affect the underlying terminal
177 file, not just the open file description associated with the particular
182 function sets the flags stored in the termios structure (initialized by
184 to a state disabling all input and output processing, giving a
186 It should be noted that there is no function to reverse this effect.
187 This is because there are a variety of processing options that could be
188 re-enabled and the correct method is for an application to snapshot the
189 current terminal state using the function
191 setting raw mode with
195 and then using another
197 with the saved state to revert to the previous terminal state.
201 function copies the parameters associated with the terminal referenced
204 to the termios structure referenced by
206 This function is allowed from a background process, however, the terminal
207 attributes may be subsequently changed by a foreground process.
211 function sets the parameters associated with the terminal from the
212 termios structure referenced by
218 the following values, as specified in the include file
220 .Bl -tag -width "TCSADRAIN"
222 The change occurs immediately.
224 The change occurs after all output written to
226 has been transmitted to the terminal.
229 should be used when changing parameters that affect output.
231 The change occurs after all output written to
233 has been transmitted to the terminal.
234 Additionally, any input that has been received but not read is discarded.
240 value, the values of the
248 The 0 baud rate is used to terminate the connection.
249 If 0 is specified as the output speed to the function
251 modem control will no longer be asserted on the terminal, disconnecting
254 If zero is specified as the input speed to the function
256 the input baud rate will be set to the same value as that specified by
257 the output baud rate.
261 is unable to make any of the requested changes, it returns -1 and
263 Otherwise, it makes all of the requested changes it can.
264 If the specified input and output baud rates differ and are a combination
265 that is not supported, neither baud rate is changed.
267 Upon successful completion, the functions
273 return -1 and the global variable
275 is set to indicate the error, as follows:
284 was not a valid file descriptor.
288 function was interrupted by a signal.
294 function was not valid, or an attempt was made to change an attribute
295 represented in the termios structure to an unsupported value.
297 The file associated with the
317 functions are expected to be compliant with the
329 function are extensions to the