Museum

Home

Lab Overview

Retrotechnology Articles

Online Manuals

⇒ tcgetattr(3) — AIX PS/2 1.2.1

Media Vault

Software Library

Restoration Projects

Artifacts Sought

Related Articles

cfgetospeed, cfsetospeed, cfgetispeed, cfsetispeed

tcsendbreak, tcdrain, tcflush, tcflow

tcgetpgrp, tcsetpgrp



TCGETATTR(3,F)              AIX Technical Reference              TCGETATTR(3,F)



-------------------------------------------------------------------------------
tcgetattr, tcsetattr



PURPOSE

Get and set terminal attributes.

LIBRARY

Standard I/O Library (libc.a)

SYNTAX

#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;
int length;

DESCRIPTION

The tcgetattr function gets the parameters associated with the object to which
fildes refers and stores them in the termios structure referenced by termios_p.
This function is allowed from a background process.  However, the information
may be subsequently changed by a foreground process.

The tcsetattr function sets the parameters associated with the terminal from
the termios structure referenced by termios_p as follows:

  o If optional_actions is TCSANOW, the change occurs immediately.

  o If optional_actions is TCSADRAIN the change occurs after all output written
    to fildes has been transmitted.  The function should be used when changing
    parameters that affect output.

  o If optional_actions is TCSAFLUSH, the change occurs after all output
    written to the object to which fildes refers has been transmitted, and all
    input that has been received but not read is discarded before the change is
    made.

The termios structure below specifies the attributes which you can get or set
with the tcgetattr and tcsetattr system calls.  The sets of allowable
attributes for various flags are defined in the file termios.h (see "termio")
or descriptions of these flags.




Processed November 7, 1990      TCGETATTR(3,F)                                1





TCGETATTR(3,F)              AIX Technical Reference              TCGETATTR(3,F)



     struct termios {
  tcflag_t          c_iflag;              /* terminal input control modes */
  tcflag_t          c_oflag;              /* terminal output control modes */
  tcflag_t          c_cflag;             /* hardware control of the terminal */
  tcflag_t          c_lflag;              /* SYSV local modes */
  tcflag_t          c_reserved[4];        /* for future expansion */
  tcflag_t          c_bflag;           /* 4bsd: newtty line discipline modes */
  struct _Winsize   c_winsize;            /* window size */
  char              c_length;             /* vertical screen length */
  char              c_pgflag;             /* paging and bell-ringing flags */
  char              c_line;               /* line discipline */
  cc_t              c_cc[NCCS];           /* control chars */
     };

Only the following fields of c_bflag can be set directly:

LCRTBS 0000001   Backspace on erase rather than echoing erase.

LPRTERA 0000002  Printing terminal erase mode.

LTILDE 0000010   Convert ~ to ' on output (for Hazeltine terminals).

LMDMBUF 0000020  Stop/start output when carrier drops.

LLITOUT 0000040  Suppress output translations.

LFLUSHO 0000200  Output is being flushed.

LETXACK 0001000  Diable style buffer hacking (unimplemented).

LCRTKIL 0002000  BS-space-BS erase entire line on line kill.

LCTLECH 0010000  Echo input control characters as ^X, delete as ^?.

LPENDIN 0020000  Retype pending input at next read or input character.

An attempt to set the other values of the c_bflag is ignored.  Other values can
be set via their SysV equivalents.  The following describes the relationships
existing between the c_bflag and the rest of the SysV termios flags:

LCRTERA   set when ECHOE is set in c_lflag.

LNOHANG   set when CLOCAL is set in c_cflag.

LNOFLASH  set when NOFLASH is set in c_lflag.

LTOSTOP   set when TOSTOP is set in c_lflag.

LDECCTQ   set when IXANY is clear in c_iflag and start char is Ctrl-Q.

LPASS8    set when CS8 is set in c_cflag and ISTRIP is clear in c_iflag.




Processed November 7, 1990      TCGETATTR(3,F)                                2





TCGETATTR(3,F)              AIX Technical Reference              TCGETATTR(3,F)



When changing terminal attributes, an application should always do a tcgetattr,
save the termios structure values returned, and then do a tcsetattr, changing
only the necessary fields.  The application should use the values saved from
the tcgetattr to reset the terminal state whenever it is done with the
terminal.  This needs to be done because terminal attributes apply to the
underlying port, not to each individual open instance.  All processes that use
the terminal see the latest attribute changes.

The tcgetattr  and tcsetattr system calls are the preferred interfaces to the
tty structure since they get and set all attributes, whereas the SysV and BSD
interfaces only get and set a subset of attributes.

RETURN VALUE

Upon successful completion, a value of 0 is returned.  Otherwise, a value of -1
is returned and errno is set to indicated the error.

ERROR CONDITIONS

If any of the following conditions occur, the tcgetattr function returns -1 and
sets errno to the corresponding value:

EBADF     The fildes argument is not a valid file descriptor.

EINVAL    The device does not support the tcgetattr function.

ENOTTY    The file associated with fildes is not a terminal.

If any of the following conditions occur, the tcsetattr function returns -1 and
sets errno to the corresponding value:

EBADF     The fildes argument is not a valid file descriptor.

EINVAL    The device does not support the tcsetattr function, 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.

RELATED INFORMATION

In this book:  "cfgetospeed, cfsetospeed, cfgetispeed, cfsetispeed,"
"tcsendbreak, tcdrain, tcflush, tcflow," and "tcgetpgrp, tcsetpgrp."











Processed November 7, 1990      TCGETATTR(3,F)                                3



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