Museum

Home

Lab Overview

Retrotechnology Articles

Online Manuals

⇒ tcsetattr(3V) — NEWS-os 4.1C

Media Vault

Software Library

Restoration Projects

Artifacts Sought

Related Articles

termio(4V)

TCGETATTR(3V)  —  NEWS-OS Programmer’s Manual

NAME

tcgetattr, tcsetattr − get and set terminal attributes

SYNOPSIS

#include <termios.h>

int tcgetattr(fd, termios_p)
int fd;
struct termios ∗termios_p;

int tcsetattr(fd, optional_actions, termios_p)
int fd;
int optional_actions;
struct termios ∗termios_p;

DESCRIPTION

These functions describe a general terminal interface that is provided to control asynchronous communications ports.  A more detailed overview of the terminal interface can be found in termio(4V). That section also describes an ioctl interface that can be used to access the same functionality.  However, the function interface described here is the preferred user interface. 

The functions described here have a termios_p argument that is a pointer to a termios structure.  This structure contains the following members:

tcflag_tc_iflag;/∗ input modes ∗/
tcflag_tc_oflag;/∗ output modes ∗/
tcflag_tc_cflag;/∗ control modes ∗/
 tcflag_tc_lflag;/∗ line discipline modes ∗/
cc_tc_cc[NCCS];/∗ control characters ∗/

These structure members are described in detail in termio(4V).

tcgetattr gets the parameters associated with the object referred to by fd and stores them in the termios structure referenced by termios_p. This function is allowed from a background process; however, the terminal attributes may be subsequently changed by a foreground process.

tcsetattr sets the parameters associated with the terminal (unless support is required from the underlying hardware that is not available) from the termios structure referenced by termios_p as follows:

• If optional_actions is TCSANOW, the change occurs immediately. 

• If optional_actions is TCSADRAIN, the change occurs after all output written to fd has been transmitted.  This function should be used when changing parameters that affect output. 

• If optional_actions is TCSAFLUSH, the change occurs after all output written to the object referred by fd has been transmitted, and all input that has been received but not read will be discarded before the change is made. 

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

RETURN VALUES

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

ERRORS

EBADF The fd argument is not a valid file descriptor. 

ENOTTY The file associated with fd is not a terminal. 

tcsetattr may set errno to:

EINVAL The optional_actions argument is not a proper value. 

An attempt was made to change an attribute represented in the termios structure to an unsupported value. 

SEE ALSO

termio(4V)

NEWS-OSRelease 4.1C

Typewritten Software • bear@typewritten.org • Edmonds, WA 98026