Museum

Home

Lab Overview

Retrotechnology Articles

Online Manuals

⇒ isatty(3C) — SunOS 5.5

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);

int isatty(int fildes);

char ∗ttyname_r(int fildes, char ∗name, int namelen);

POSIX

cc [ flag... ] file ... −D_POSIX_PTHREAD_SEMANTICS [ library... ]

int ttyname_r(int fildes, char ∗name, size_t namesize);

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 same functionality as ttyname() except that the caller must supply a buffer name with length namelen to store the result; this buffer must be at least _POSIX_PATH_MAX in size (defined in <limits.h>).  The POSIX version of ttyname_r() takes a namesize parameter of type size_t. 

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.  The POSIX ttyname_r() returns zero if successful, or the error number upon failure. 

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

When compiling multithread programs, see Intro(3), Notes On Multithread Applications.

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, and should be used instead.  isatty() is MT-Safe in multi-thread applications. 

Solaris 2.4 and earlier releases provided definitions of the ttyname_r() interface as specified in POSIX.1c Draft 6.  The final POSIX.1c standard changed the interface as described above.  Support for the Draft 6 interface is provided for compatibility only and may not be supported in future releases.  New applications and libraries should use the POSIX standard interface. 

SunOS 5.5  —  Last change: 22 Aug 1995

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