DOC HOME SITE MAP MAN PAGES GNU INFO SEARCH PRINT BOOK
 

ttyname(3C)


ttyname, ttyname_r, isatty -- find name of a terminal

Synopsis

#include <stdlib.h>

char *ttyname(int fildes);

int 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 pathname of the terminal device associated with file descriptor fildes.

ttyname_r stores the null-terminated pathname of the terminal device associated with the file descriptor fildes in the string pointed to by buffer (up to buflen bytes).

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 a value of 0 on success, and a non-zero return indicates an error. The return value indicates the errno.

ttyname_r returns NULL and 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 multithreaded applications.

The older ttyname_r interface:

   char *ttyname_r(int fildes, char *buffer, size_t buflen);
is available if _SIMPLE_R is defined.

References

ttymap(1M), ttyslot(3C), ttysrch(4)
© 2004 The SCO Group, Inc. All rights reserved.
UnixWare 7 Release 7.1.4 - 25 April 2004