ttyname(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 *buffer, size_t buflen);
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.
ttyname_r stores in the string pointed to by buffer (up to
buflen bytes) the null-terminated path name of the terminal
device associated with the file descriptor fildes.
isatty returns 1 if fildes is associated with a terminal
device, 0 otherwise.
Files
/dev/*
Return Values
ttyname and ttyname_r return a NULL pointer if fildes does not
describe a terminal device in directory /dev.
ttyname_r returns buffer on success.
Errors
ttyname_r returns NULL and sets errno to ERANGE if buflen is
smaller than the length of the string to be returned.
NOTICES
The value returned by ttyname points to static data whose
content is overwritten by each call.
Use ttyname_r for multi-threaded applications.
Copyright 1994 Novell, Inc. Page 1