ttyname(3C)
find name of a terminal
From the original Amiga UNIX 2.1 manual. Some things it mentions may not be in this release.
NAME
ttyname, isatty - find name of a terminal
SYNOPSIS
#include <stdlib.h> char *ttyname (int fildes); int isatty (int fildes);
DESCRIPTION
ttyname returns a pointer to a string containing the null-terminated path name of the terminal device associated with file descriptor fildes.
isatty returns 1 if fildes is associated with a terminal device, 0 otherwise.
FILES
/dev/*
DIAGNOSTICS
ttyname returns a NULL pointer if fildes does not describe a terminal device in directory /dev.
NOTES
The return value points to static data whose content is overwritten by each call.