change the terminal control settings for a device
#include <termios.h> int tcsetattr( int fildes, int optional_actions, const struct termios *termios_p );
The tcsetattr() function sets the current terminal control settings for the opened device indicated by fildes to the values stored in the structure pointed to by termios_p.
The operation of tcsetattr() depends on the values in optional_actions:
The termios control structure is defined in <termios.h>, and is described under the tcgetattr() function.
We recommend that the dev_mode() function be used in situations where only the principal terminal modes (ECHO, ISIG, ICANON and OPOST) are being affected. |
#include <termios.h> void main() { raw( 0 ); /* * Stdin is now "raw" */ unraw ( 0 ); } int raw( fd ) int fd; { struct termios termios_p; if( tcgetattr( fd, &termios_p ) ) return( -1 ); termios_p.c_cc[VMIN] = 1; termios_p.c_cc[VTIME] = 0; termios_p.c_lflag &= ~( ECHO|ICANON|ISIG| ECHOE|ECHOK|ECHONL ); termios_p.c_oflag &= ~( OPOST ); return( tcsetattr( fd, TCSADRAIN, &termios_p ) ); } int unraw( fd ) int fd; { struct termios termios_p; if( tcgetattr( fd, &termios_p ) ) return( -1 ); termios_p.c_lflag |= ( ECHO|ICANON|ISIG| ECHOE|ECHOK|ECHONL ); termios_p.c_oflag |= ( OPOST ); return( tcsetattr( fd, TCSADRAIN, &termios_p ) ); }
POSIX 1003.1
Safety: | |
---|---|
Interrupt handler | No |
Signal handler | Yes |
Thread | Yes |
dev_mode(), errno, select(), tcgetattr()