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

Technical Reference: Base Operating System and Extensions , Volume 2


ttyname or isatty Subroutine

Purpose

Gets the name of a terminal or determines if the device is a terminal.

Library

Standard C Library (libc.a)

Syntax

#include <unistd.h>


char *ttyname( FileDescriptor)
int FileDescriptor;

int isatty(FileDescriptor)
int FileDescriptor;

Description

Attention: Do not use the ttyname subroutine in a multithreaded environment.

The ttyname subroutine gets the path name of a terminal.

The isatty subroutine determines if the file descriptor specified by the FileDescriptor parameter is associated with a terminal.

The isatty subroutine does not necessarily indicate that a person is available for interaction, since nonterminal devices may be connected to the communications line.

Parameters


FileDescriptor Specifies an open file descriptor.

Return Values

The ttyname subroutine returns a pointer to a string containing the null-terminated path name of the terminal device associated with the file descriptor specified by the FileDescriptor parameter. A null pointer is returned and the errno global variable is set to indicate the error if the file descriptor does not describe a terminal device in the /dev directory.

The return value of the ttyname subroutine may point to static data whose content is overwritten by each call.

If the specified file descriptor is associated with a terminal, the isatty subroutine returns a value of 1. If the file descriptor is not associated with a terminal, a value of 0 is returned and the errno global variable is set to indicate the error.

Error Codes

The ttyname and isatty subroutines are unsuccessful if one of the following is true:

EBADF The FileDescriptor parameter does not specify a valid file descriptor.
ENOTTY The FileDescriptor parameter does not specify a terminal device.

Implementation Specifics

These subroutines are part of Base Operating System (BOS) Runtime.

Files


/dev/* Terminal device special files.

Related Information

The ttyslot (ttyslot Subroutine) subroutine.

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


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