Museum

Home

Lab Overview

Retrotechnology Articles

Online Manuals

⇒ isatty(3C) — SunOS 5.2

Media Vault

Software Library

Restoration Projects

Artifacts Sought

Related Articles

gettext(3I)

setlocale(3C)

ttyname(3C)

NAME

ttyname, ttyname_r, isatty − find name of a terminal

SYNOPSIS

#include <stdlib.h>

char ∗ttyname(int fildes);

char ∗ttyname_r(int fildes, char ∗buf, int len);

int isatty(int fildes);

MT-LEVEL

See the NOTES section of this page. 

DESCRIPTION

ttyname() returns a pointer to a string containing the null-terminated path name of the terminal device associated with file descriptor fildes.

ttyname_r() has the equivalent functionality to ttyname() except that a buffer buf with length len must be supplied by the caller to store the result.  buf must be at least _POSIX_PATH_MAX in size (defined in limits.h). 

isatty() returns 1 if fildes is associated with a terminal device, 0 otherwise. 

RETURN VALUES

ttyname() and ttyname_r() return a NULL pointer if fildes does not describe a terminal device in directory /dev. 

ERRORS

ttyname_r() will fail if the following is true:

ERANGE The size of the buffer is smaller than the result to be returned. 

FILES

/dev/∗

SEE ALSO

gettext(3I), setlocale(3C)

NOTES

If the application is linked with −lintl, then messages printed from this function are in the native language specified by the LC_MESSAGES locale category; see setlocale(3C). 

The return value points to static data whose content is overwritten by each call. 

ttyname() is unsafe in multi-thread applications.  ttyname_r() is MT-Safe, andshould be used instead.  isatty() is MT-Safe in multi-thread applications. 

SunOS 5.2  —  Last change: 22 Jan 1993

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