.\" Copyright (c) 1991, 1993
.\" The Regents of the University of California. All rights reserved.
.\" Redistribution and use in source and binary forms, with or without
.\" modification, are permitted provided that the following conditions
.\" 1. Redistributions of source code must retain the above copyright
.\" notice, this list of conditions and the following disclaimer.
.\" 2. Redistributions in binary form must reproduce the above copyright
.\" notice, this list of conditions and the following disclaimer in the
.\" documentation and/or other materials provided with the distribution.
.\" 3. All advertising materials mentioning features or use of this software
.\" must display the following acknowledgement:
.\" This product includes software developed by the University of
.\" California, Berkeley and its contributors.
.\" 4. Neither the name of the University nor the names of its contributors
.\" may be used to endorse or promote products derived from this software
.\" without specific prior written permission.
.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" @(#)tcsetattr.3 8.1 (Berkeley) 6/4/93
.Nd manipulating the termios structure
.Fn cfgetispeed "struct termios *t"
.Fn cfsetispeed "struct termios *t" "speed_t speed"
.Fn cfgetospeed "struct termios *t"
.Fn cfsetospeed "struct termios *t" "speed_t speed"
.Fn cfsetspeed "struct termios *t" "speed_t speed"
.Fn cfmakeraw "struct termios *t"
.Fn tcgetattr "int fd" "struct termios *t"
.Fn tcsetattr "int fd" "int action" "struct termios *t"
functions are provided for getting and setting the termios structure.
functions are provided for getting and setting the baud rate values in
The effects of the functions on the terminal as described below
do not become effective, nor are all errors detected, until the
Certain values for baud rates set in the termios structure and passed to
These are discussed in the portion of the manual page that describes the
.Sh GETTING AND SETTING THE BAUD RATE
The input and output baud rates are found in the termios structure.
is typdef'd in the include file
The value of the integer corresponds directly to the baud rate being
represented, however, the following symbolic values are defined.
#endif /*_POSIX_SOURCE */
function returns the input baud rate in the termios structure referenced by
function sets the input baud rate in the termios structure referenced by
function returns the output baud rate in the termios structure referenced by
function sets the output baud rate in the termios structure referenced by
function sets both the input and output baud rate in the termios structure
Upon successful completion, the functions
Otherwise, a value of -1 is returned and the global variable
is set to indicate the error.
.Sh GETTING AND SETTING THE TERMIOS STATE
This section describes the functions that are used to control the general
Unless otherwise noted for a specific command, these functions are restricted
from use by background processes.
Attempts to perform these operations shall cause the process group to be sent
If the calling process is blocking or ignoring SIGTTOU signals, the process
is allowed to perform the operation and the SIGTTOU signal is not sent.
In all the functions, although
is an open file descriptor, the functions affect the underlying terminal
file, not just the open file description associated with the particular
function sets the flags stored in the termios structure to a state disabling
all input and output processing, giving a
It should be noted that there is no function to reverse this effect.
This is because there are a variety of processing options that could be
re-enabled and the correct method is for an application to snapshot the
current terminal state using the function
with the saved state to revert to the previous terminal state.
function copies the parameters associated with the terminal referenced
in the termios structure referenced by
This function is allowed from a background process, however, the terminal
attributes may be subsequently changed by a foreground process.
function sets the parameters associated with the terminal from the
termios structure referenced by
the following values, as specified in the include file
.Bl -tag -width "TCSADRAIN"
The change occurs immediately.
The change occurs after all output written to
has been transmitted to the terminal.
should be used when changing parameters that affect output.
The change occurs after all output written to
has been transmitted to the terminal
Additionally, any input that has been received but not read is discarded.
The 0 baud rate is used to terminate the connection.
If 0 is specified as the output speed to the function
modem control will no longer be asserted on the terminal, disconnecting
If zero is specified as the input speed to the function
the input baud rate will be set to the same value as that specified by
is unable able to make any of the requested changes, it returns -1 and
Otherwise, it makes all of the requested changes it can.
If the specified input and output baud rates differ and are a combination
that is not supported, neither baud rate is changed.
Upon successful completion, the functions
return -1 and the global variable
is set to indicate the error, as follows:
was not a valid file descriptor.
function was interrupted by a signal.
function was not valid, or an attempt was made to change an attribute
represented in the termios structure to an unsupported value.
The file associated with the
functions are expected to be compliant with the
function are extensions to the