test, and set or clear, input/output modes for a terminal device
#include <sys/dev.h> unsigned dev_mode( int fd, unsigned mode, unsigned mask );
The dev_mode() function is used to test, and optionally set (or clear), one of the input/output modes pertaining to the terminal device associated with fd.
Any mode bits that are set in mask are set to the corresponding bit in mode. The value of the terminal mode before this operation is applied is returned.
At least the following terminal modes are defined in <sys/dev.h>:
The absence of this mode is usually known as "raw" mode, and has the effect of disabling line editing keys, and making all keys available to programs as they are received.
The previous terminal mode of the device associated with fd. If an error occurs, -1 is returned and errno is set.
#include <sys/dev.h> int main( void ) { unsigned old_mode; /* Examine the current terminal mode */ old_mode = dev_mode( 0, 0, 0 ); /* Go completely "raw" by disabling everything */ dev_mode( 0, 0, _DEV_MODES ); /* Put terminal in fully edited (default) mode */ dev_mode( 0, _DEV_MODES, _DEV_MODES ); /* Turn off echo without affecting other modes */ dev_mode( 0, 0, _DEV_ECHO ); /* Turn on output expansions */ dev_mode( 0, _DEV_OPOST, _DEV_OPOST ); /* Restore the terminal to its original mode */ dev_mode( 0, old_mode, _DEV_MODES ); }
QNX
Safety: | |
---|---|
Interrupt handler | No |
Signal handler | Yes, but modifies errno |
Thread | Yes |
errno, tcgetattr(), tcsetattr()