If successful, tcgetattr
returns @math{0}. A return value of @math{-1}
indicates an error. The following errno
error conditions are
defined for this function:
EBADF
ENOTTY
The when argument specifies how to deal with input and output already queued. It can be one of the following values:
TCSANOW
TCSADRAIN
TCSAFLUSH
TCSADRAIN
, but also discards any queued input.
TCSASOFT
TCSASOFT
is exactly the same as setting the CIGNORE
bit in the c_cflag
member of the structure termios-p points
to. See section Control Modes, for a description of CIGNORE
.
If this function is called from a background process on its controlling
terminal, normally all processes in the process group are sent a
SIGTTOU
signal, in the same way as if the process were trying to
write to the terminal. The exception is if the calling process itself
is ignoring or blocking SIGTTOU
signals, in which case the
operation is performed and no signal is sent. See section Job Control.
If successful, tcsetattr
returns @math{0}. A return value of
@math{-1} indicates an error. The following errno
error
conditions are defined for this function:
EBADF
ENOTTY
EINVAL
when
argument is not valid, or there is
something wrong with the data in the termios-p argument.
Although tcgetattr
and tcsetattr
specify the terminal
device with a file descriptor, the attributes are those of the terminal
device itself and not of the file descriptor. This means that the
effects of changing terminal attributes are persistent; if another
process opens the terminal file later on, it will see the changed
attributes even though it doesn't have anything to do with the open file
descriptor you originally specified in changing the attributes.
Similarly, if a single process has multiple or duplicated file descriptors for the same terminal device, changing the terminal attributes affects input and output to all of these file descriptors. This means, for example, that you can't open one file descriptor or stream to read from a terminal in the normal line-buffered, echoed mode; and simultaneously have another file descriptor for the same terminal that you use to read from it in single-character, non-echoed mode. Instead, you have to explicitly switch the terminal back and forth between the two modes.
Go to the first, previous, next, last section, table of contents.