TCGETATTR

Section: Misc. Reference Manual Pages (3P)
Updated: August 1, 1992
Index Return to Main Contents
 

NAME

tcgetattr, tcsetattr - get and set terminal attributes  

SYNOPSIS

#include <termios.h>

int tcgetattr(int fildes, struct termios *termios_p);

int tcsetattr(int fildes, int actions, const struct termios *termios_p);  

DESCRIPTION

The tcgetattr function gets the parameters associated with an open terminal file, passed through the fildes argument. It stores the parameters in the termios structure passed through the argument tp. This function may be called from a background process; however, the terminal attributes may be subsequently changed by a foreground process.

The tcsetattr function sets the parameters associated with the terminal to those in the termios structure referenced by termios_p. The possible values of the actions argument are the following constants defined in <termios.h>:

Constant
Description
TCSANOW
Set the terminal attributes immediately.
TCSADRAIN
Set the terminal attributes after all output that has already been written to fildes has been transmitted.
TCSAFLUSH
Set the terminal attributes after all output that has already been written to fildes has been transmitted. Discard all input that has not been read before setting the attributes.

A process that is not in the foreground process group cannot call tcsetattr for its controlling terminal.

The tcsetattr function returns success if it was able to perform any of the requested actions, even if some of the requested actions could not be performed.  

RETURN VALUE

Upon successful completion tcgetattr and tcsetattr return a value of zero. Otherwise, a value of -1 is returned and errno is set to indicate the error.  

ERRORS

Tcgetattr and tcsetattr shall return -1 and set 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.

The following errors may be associated with tcsetattr:

[EINTR]
A signal interrupted the tcsetattr function.
[EINVAL]
The value of the pgrp_id argument is not valid.
 

SEE ALSO

termios(4P)


 

Index

NAME
SYNOPSIS
DESCRIPTION
RETURN VALUE
ERRORS
SEE ALSO

This document was created by man2html, using the manual pages.
Time: 00:57:24 GMT, September 26, 2024