tcgetattr(3C) tcgetattr(3C)
NAME
tcgetattr, tcsetattr - Get or set terminal attributes.
SYNOPSIS
#include <termios.h>
int tcgetattr (fildes, termiosp)
int fildes;
struct termios *termiosp;
int tcsetattr (fildes, optionalactions, termiosp)
int fildes;
int optionalactions;
struct termios *termiosp;
DESCRIPTION
The tcgetattr() and tcsetattr() functions are defined in the
POSIX 1003.1 standard and used in the OCS and BCS standards.
CX/UX applications which are not POSIX/OCS/BCS compliant can
use these functions.
tcgetattr gets the attributes associated with the terminal
device referenced by fildes. These attributes are returned
to the user via the termios structure pointed to by
termios_p. A background process may call this function, but
the attributes may be changed by a subsequent foreground
process call to tcsetattr.
Tcsetattr sets the attributes associated with the terminal
device referenced by fildes. These attributes are passed
into the system via the user modified termios structure
pointed to by termios_p. The methods of performing this
action are described by one of the optional_actions as fol-
lows:
TCSANOW
The change shall occur immediately.
TCSADRAIN
The change shall occur after all output written to
fildes has been transmitted (drained). This
option should be used when changing parameters
that affect output (e.g., Preventing output from
disappearing at low baud rates).
TCSAFLUSH
The change shall occur after 1) all output written
to fildes has been transmitted (drained), and 2)
all input that has been received but not read has
been discarded (flushed).
The optional_actions constants are defined in <termios.h>.
Page 1 CX/UX Programmer's Reference Manual
tcgetattr(3C) tcgetattr(3C)
Background processes may not call tcsetattr. Attempts to do
so will result in a SIGTTOU signal being sent to the calling
process and all members of its process group. The SIGTTOU
signal will stop the calling process and all members of its
process group unless the calling process is blocking or
ignoring this signal.
NOTES
CX/UX does not support separate line rates for terminal dev-
ices. As a result, all references to input rates actually
refer to output rates. Therefore, the input rate should be
specified by the same value as the output rate when using
tcsetattr. It is best to use cfsetispeed(3C) with its argu-
ment speed set to B0 allowing the input rate to be automati-
cally specified by the value of the output baud rate. This
assumes that cfsetospeed(3C) has been previously called. If
both input and output baud rates do not match, the tcsetattr
function call will fail with errno set to [EINVAL].
SEE ALSO
cfsetispeed(3C), cfgetispeed(3C), cfsetospeed(3C),
cfgetospeed(3C), termios(7)
DIAGNOSTICS
Upon successful completion, a value of zero is returned by
both functions. If not, a value of -1 is returned and errno
is set.
Errno is set to one of the following values for tcgetattr:
[EBADF] Fildes is not a valid open file descriptor.
[ENOTTY] Fildes is not associated with a terminal dev-
ice.
Errno is set to one of the following values for tcsetattr:
[EBADF] Fildes is not a valid open file descriptor.
[EINVAL] The optional_actions argument is not a proper
value as defined in <termios.h>, or an
attempt was made to change an attribute
represented in the termios structure to an
unsupported value (e.g., input baud rate not
equivalent to output baud rate).
[ENOTTY] Fildes is not associated with a terminal dev-
ice.
Page 2 CX/UX Programmer's Reference Manual