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,
|
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:
If this function is called from a background process on its controlling
terminal, normally all processes in the process group are sent a
If successful,
|
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.