Museum

Home

Lab Overview

Retrotechnology Articles

⇒ Online Manual

Media Vault

Software Library

Restoration Projects

Artifacts Sought

Related Articles

ttyslot(3)

ttyname(3)  —  Subroutines

NAME

ttyname, isatty, ttyname_r −  Gets the name of a terminal

LIBRARY

Standard C Library (libc.a)

SYNOPSIS

char ∗ttyname(
int file-descriptor );

int isatty(
int file-descriptor );

int ttyname_r(
int file-descriptor,
char ∗buffer,
int len );

PARAMETERS

file-descriptorSpecifies an open file descriptor. 

bufferPoints to a buffer in which the terminal name is stored. 

lenSpecifies the length of the buffer pointed to by the buffer parameter. 

DESCRIPTION

The ttyname() function gets the name of a terminal.  It returns a pointer to a string containing the null-terminated pathname of the terminal device associated with the file-descriptor parameter. 

The isatty() function determines if the device associated with the file-descriptor parameter is a terminal.  If so, the isatty() function returns a value of 1.  If the file descriptor is not associated with a terminal, a value of 0 (zero) is returned. 

The ttyname_r() function is the reentrant version of the ttyname() function.  Upon successful completion, the terminal name is stored as a null-terminated string in the buffer pointed to by the buffer parameter. 

NOTES

AES Support Level: Full use

RETURN VALUES

The ttyname() function returns a pointer to a string which is static data that is overwritten by each call.  A null pointer is returned if the file-descriptor parameter does not describe a terminal device in the directory /dev. 

The isatty() function returns a value of 1 if the specified file descriptor is associated with a terminal, and 0 (zero) otherwise. 

The ttyname_r() function returns 0 (zero) if successful.  Otherwise, −1 is returned. 

ERRORS

If the ttyname_r() function fails, errno may be set to the following value:

[EINVAL]The buffer parameter is a null pointer or the len parameter was too short to store the string. 

If the isatty() function fails, errno may be set to the following value:

[ENOTTY]The file associated with filedes is not a terminal. 

RELATED INFORMATION

Functions: ttyslot(3)

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