[ Bottom of Page | Previous Page | Next Page | Contents | Index | Library Home | Legal | Search ]

Technical Reference: Base Operating System and Extensions, Volume 2

tcgetattr Subroutine

Purpose

Gets terminal state.

Library

Standard C Library (libc.a)

Syntax

#include <termios.h>


int tcgetattr ( FileDescriptor TermiosPointer)
int FileDescriptor;
struct termios *TermiosPointer;

Description

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

Whether or not the terminal device supports differing input and output baud rates, the baud rates stored in the termios structure returned by the tcgetattr subroutine reflect the actual baud rates, even if they are equal.

Note
If differing baud rates are not supported, returning a value of 0 as the input baud rate is obsolete.

Parameters

FileDescriptor Specifies an open file descriptor.
TermiosPointer Points to a termios structure.

Return Values

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

Error Codes

The tcgetattr subroutine is unsuccessful if one of the following is true:

EBADF The FileDescriptor parameter does not specify a valid file descriptor.
ENOTTY The file associated with the FileDescriptor parameter is not a terminal.

Examples

To get the current terminal state information, enter:

rc = tcgetattr(stdout, &my_termios);

Related Information

The tcsetattr (tcsetattr Subroutine) subroutine.

The Input and Output Handling Programmer's Overview in AIX 5L Version 5.2 General Programming Concepts: Writing and Debugging Programs.

[ Top of Page | Previous Page | Next Page | Contents | Index | Library Home | Legal | Search ]