ttyname(3C) ttyname(3C)
ttyname, ttyname_r, isatty - find name of a terminal
#include <stdlib.h>
#include <unistd.h>
char *ttyname (int fildes);
int ttyname_r (int fildes, char *buf, size_t buflen);
int isatty (int fildes);
ttyname returns a pointer to a string containing the null-terminated path
name of the terminal device associated with file descriptor fildes.
ttyname_r is a reentrant version of ttyname where buf and buflen give the
location and maximum size of where the resultant string should be placed.
The maximum length of the terminal name is {TTY_NAME_MAX}. sysconf(3C)
may be used to determine this value.
isatty returns 1 if fildes is associated with a terminal device, 0
otherwise.
/dev/*
ttyname returns a NULL pointer if fildes does not describe a terminal
device in directory /dev.
ttyname_r returns 0 on success or an error number on failure. If fildes
doesn't refer to a valid file descriptor, EBADF is returned. If fildes
doesn't refer to a valid terminal device, ENOTTY is returned. If the
value of buflen is smaller than the length of the string to be returned
including the terminating null character, ERANGE is returned.
The return value of ttyname points to static data whose content is
overwritten by each call.
PPPPaaaaggggeeee 1111 [ Back ]
|