TCATTR(S) UNIX System V TCATTR(S)
Name
tcgetattr, tcsetattr - state functions
Syntax
#include <termios.h>
int tcgetattr (fildes, termios_p);
int fildes;
struct termios *termios_p;
int tcsetattr (fildes, optional_actions, termios_p);
int fildes, optional_actions;
struct termios *termios_p;
Description
The tcgetattr() function gets the parameters associated with
the object referred to by fildes and store them in the
termios structure referenced by termios_p. This function is
allowed from a background process; however the terminal
attributes may subsequently be changed by a foreground
process.
The tcsetattr() function shall set the parameters associated
with the terminal (unless support is required from the
underlying hardware that is not available) from the termios
structure referenced bytermios_p as follows:
1. If optional_actions is TCSANOW, the change occurs
immediately.
2. If optional_actions is TCSADRAIN, the change occurs
after all output written to fildes has been
transmitted. This function should be used when changing
parameters that affect output.
3. If optional_actions is TCSAFLUSH, the change occurs
after all output written to fildes has been transmitted
and all input received but not read is discarded.
The symbolic constants for the values of the
optional_actions are defined in <termios.h>.
Return Value
Upon successful completion, these routines return a value of
0. Otherwise, a value of -1 is reutrned and errno is set to
indicate the error.
Errors
If any of the following conditions occur, tcgetattr()
returns -1 and sets errno to the corresponding value:
EBADF The fildes argument is not a valid file descriptor.
ENOTTY The file associated with fildes is not a terminal.
If any of the following conditions occur, tcsetattr()
returns -1 and sets errno to the corresponding value:
EBADF The fildes argument is not a valid file
descriptor.
EINVAL The optional_actions argument is not a proper
value, or an attempt was made to change an
attribute represented in the termios structure to
an unsupported value.
ENOTTY The file associated with fildes is not a terminal.
See Also
tcflow(S)
Standards Conformance
tcgetattr and tcsetattr are conformant with:
AT&T SVID Issue 2, Select Code 307-127.
(printed 6/20/89)