1TTYNAME(3P)                POSIX Programmer's Manual               TTYNAME(3P)
2
3
4

PROLOG

6       This  manual  page is part of the POSIX Programmer's Manual.  The Linux
7       implementation of this interface may differ (consult the  corresponding
8       Linux  manual page for details of Linux behavior), or the interface may
9       not be implemented on Linux.
10

NAME

12       ttyname, ttyname_r - find the pathname of a terminal
13

SYNOPSIS

15       #include <unistd.h>
16
17       char *ttyname(int fildes);
18
19
20       int ttyname_r(int fildes, char *name, size_t namesize);
21
22

DESCRIPTION

24       The ttyname() function shall return a pointer to a string containing  a
25       null-terminated  pathname of the terminal associated with file descrip‐
26       tor fildes. The return value may point to static data whose content  is
27       overwritten by each call.
28
29       The  ttyname()  function  need not be reentrant. A function that is not
30       required to be reentrant is not required to be thread-safe.
31
32       The ttyname_r() function shall store the  null-terminated  pathname  of
33       the  terminal associated with the file descriptor fildes in the charac‐
34       ter array referenced by name. The array is namesize characters long and
35       should  have space for the name and the terminating null character. The
36       maximum length of the terminal name shall be {TTY_NAME_MAX}.
37

RETURN VALUE

39       Upon successful completion, ttyname()  shall  return  a  pointer  to  a
40       string.  Otherwise,  a  null pointer shall be returned and errno set to
41       indicate the error.
42
43       If successful, the ttyname_r() function shall return  zero.  Otherwise,
44       an error number shall be returned to indicate the error.
45

ERRORS

47       The ttyname() function may fail if:
48
49       EBADF  The fildes argument is not a valid file descriptor.
50
51       ENOTTY The fildes argument does not refer to a terminal.
52
53
54       The ttyname_r() function may fail if:
55
56       EBADF  The fildes argument is not a valid file descriptor.
57
58       ENOTTY The fildes argument does not refer to a terminal.
59
60       ERANGE The  value  of namesize is smaller than the length of the string
61              to be returned including the terminating null character.
62
63
64       The following sections are informative.
65

EXAMPLES

67       None.
68

APPLICATION USAGE

70       None.
71

RATIONALE

73       The term ``terminal'' is used instead of the historical term ``terminal
74       device'' in order to avoid a reference to an undefined term.
75
76       The  thread-safe  version  places  the terminal name in a user-supplied
77       buffer and returns a non-zero value if it  fails.  The  non-thread-safe
78       version may return the name in a static data area that may be overwrit‐
79       ten by each call.
80

FUTURE DIRECTIONS

82       None.
83

SEE ALSO

85       The Base Definitions volume of IEEE Std 1003.1-2001, <unistd.h>
86
88       Portions of this text are reprinted and reproduced in  electronic  form
89       from IEEE Std 1003.1, 2003 Edition, Standard for Information Technology
90       -- Portable Operating System Interface (POSIX),  The  Open  Group  Base
91       Specifications  Issue  6,  Copyright  (C) 2001-2003 by the Institute of
92       Electrical and Electronics Engineers, Inc and The Open  Group.  In  the
93       event of any discrepancy between this version and the original IEEE and
94       The Open Group Standard, the original IEEE and The Open Group  Standard
95       is  the  referee document. The original Standard can be obtained online
96       at http://www.opengroup.org/unix/online.html .
97
98
99
100IEEE/The Open Group                  2003                          TTYNAME(3P)
Impressum