DOC HOME SITE MAP MAN PAGES GNU INFO SEARCH PRINT BOOK
 

tcattr(S)


tcgetattr, tcsetattr -- state functions

Syntax

cc . . . -lc

#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 stores 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 fildes argument is an open file descriptor associated with a terminal. If the terminal device does not support split baud rates, the input baud rate stored in the termios structure is set to zero.

The tcsetattr function sets the parameters associated with the terminal referred to by the open file descriptor fildes and stores them in the termios structure referenced by termios_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. Use tcsetattr 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 so far received but not read is discarded before the change is made.

The symbolic constants for the values of the optional_actions are defined in <termios.h>.

If the output baud rate stored in the termios structure pointed to by termios_p is the zero baud rate, B0, the modem control lines are no longer asserted. Normally this disconnects the line.

If the input baud rate stored in the termios structure pointed to by termios_p is zero, the input baud rate given to the hardware is the same as the output baud rate stored in the termios structure.

If POSIX_JOB_CONTROL is defined, attempts to use the tcsetattr routine from a process that is a member of a background process group on a fildes associated with its controlling terminal, cause the process group to be sent a SIGTTOU signal. If the calling process is blocking or ignoring SIGTTOU signals, the process is allowed to perform the operation, and no signal is sent.

Note

If trying to change baud rates, applications should first call tcsetattr to determine what baud rates were actually selected, and then call tcgetattr.

Return value

Upon successful completion, these routines return a value of 0. Otherwise, a value of -1 is returned 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:

X/Open Portability Guide, Issue 3, 1989 ;
and IEEE POSIX Std 1003.1-1990 System Application Program Interface (API) [C Language] (ISO/IEC 9945-1) .


© 2003 Caldera International, Inc. All rights reserved.
SCO OpenServer Release 5.0.7 -- 11 February 2003