![]() |
![]() |
![]() |
![]() |
Change the terminal control settings for a device
#include <termios.h> int tcsetattr( int fildes, int optional_actions, const struct termios *termios_p );
libc
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>. For more information, see tcgetattr().
#include <stdlib.h> #include <termios.h> int main( void ) { raw( 0 ); /* * Stdin is now "raw" */ unraw ( 0 ); return EXIT_SUCCESS; } 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 ) ); }
Safety: | |
---|---|
Cancellation point | No |
Interrupt handler | No |
Signal handler | Yes |
Thread | Yes |
errno, select(), tcgetattr(), termios
![]() |
![]() |
![]() |
![]() |