tcattr(S) 6 January 1993 tcattr(S) Name 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 termiosp. This function is allowed from a background process; however the terminal attributes may subsequently be changed by a foreground pro- cess. 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 termiosp as follows: 1. If optionalactions is TCSANOW, the change occurs immediately. 2. If optionalactions is TCSADRAIN, the change occurs after all output written to fildes has been transmitted. Use tcsetattr when changing parameters that affect output. 3. If optionalactions 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 optionalactions are defined in <termios.h>. If the output baud rate stored in the termios structure pointed to by termiosp 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 termiosp is zero, the input baud rate given to the hardware is the same as the output baud rate stored in the termios structure. If POSIXJOBCONTROL 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. Other- wise, 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 optionalactions argument is not a proper value, or an attempt was made to change an attribute represented in the ter- mios 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; 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).