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
11

NAME

13       ttyname, ttyname_r — find the pathname of a terminal
14

SYNOPSIS

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

DESCRIPTION

22       The ttyname() function shall return a pointer to a string containing  a
23       null-terminated  pathname of the terminal associated with file descrip‐
24       tor fildes.  The application shall not modify the string returned.  The
25       returned  pointer  might  be invalidated or the string content might be
26       overwritten by a subsequent call to ttyname().
27
28       The ttyname() function need not be thread-safe.
29
30       The ttyname_r() function shall store the  null-terminated  pathname  of
31       the  terminal associated with the file descriptor fildes in the charac‐
32       ter array referenced by name.  The array is  namesize  characters  long
33       and  should have space for the name and the terminating null character.
34       The maximum length of the terminal name shall be {TTY_NAME_MAX}.
35

RETURN VALUE

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

ERRORS

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

EXAMPLES

63       None.
64

APPLICATION USAGE

66       None.
67

RATIONALE

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

FUTURE DIRECTIONS

78       None.
79

SEE ALSO

81       The Base Definitions volume of POSIX.1‐2008, <unistd.h>
82
84       Portions of this text are reprinted and reproduced in  electronic  form
85       from IEEE Std 1003.1, 2013 Edition, Standard for Information Technology
86       -- Portable Operating System Interface (POSIX),  The  Open  Group  Base
87       Specifications Issue 7, Copyright (C) 2013 by the Institute of Electri‐
88       cal and Electronics Engineers,  Inc  and  The  Open  Group.   (This  is
89       POSIX.1-2008  with  the  2013  Technical Corrigendum 1 applied.) In the
90       event of any discrepancy between this version and the original IEEE and
91       The  Open Group Standard, the original IEEE and The Open Group Standard
92       is the referee document. The original Standard can be  obtained  online
93       at http://www.unix.org/online.html .
94
95       Any  typographical  or  formatting  errors that appear in this page are
96       most likely to have been introduced during the conversion of the source
97       files  to  man page format. To report such errors, see https://www.ker
98       nel.org/doc/man-pages/reporting_bugs.html .
99
100
101
102IEEE/The Open Group                  2013                          TTYNAME(3P)
Impressum