GETTING AND SETTING THE TERMIOS STATE
This section describes the functions that are used to control the general terminal interface. 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 a SIGTTOU signal. 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 fd is an open file descriptor, the functions affect the underlying terminal file, not just the open file description associated with the particular file descriptor.
The cfmakeraw function sets the flags stored in the termios structure to a state disabling all input and output processing, giving a "raw I/O path". 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 tcgetattr, setting raw mode with cfmakeraw and the subsequent tcsetattr, and then using another tcsetattr with the saved state to revert to the previous terminal state.
The tcgetattr function copies the parameters associated with the terminal referenced by fd in the termios structure referenced by tp. This function is allowed from a background process, however, the terminal attributes may be subsequently changed by a foreground process.
The tcsetattr function sets the parameters associated with the terminal from the termios structure referenced by tp. The action argument is created by or ing the following values, as specified in the include file
.In termios.h .