Node:Mode Functions, Next:Setting Modes, Previous:Mode Data Types, Up:Terminal Modes
int tcgetattr (int filedes, struct termios *termios-p) | Function |
This function is used to examine the attributes of the terminal
device with file descriptor filedes. The attributes are returned
in the structure that termios-p points to.
If successful, tcgetattr returns 0. A return value of -1
indicates an error. The following errno error conditions are
defined for this function:
|
int tcsetattr (int filedes, int when, const struct termios *termios-p) | Function |
This function sets the attributes of the terminal device with file
descriptor filedes. The new attributes are taken from the
structure that termios-p points to.
The when argument specifies how to deal with input and output
already queued. It can be one of the following values:
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 Job Control.
If successful, tcsetattr returns 0. A return value of
-1 indicates an error. The following errno error
conditions are defined for this function:
|
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.