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       int ttyname_r(int fildes, char *name, size_t namesize);
19

DESCRIPTION

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

RETURN VALUE

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

ERRORS

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

EXAMPLES

64       None.
65

APPLICATION USAGE

67       None.
68

RATIONALE

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

FUTURE DIRECTIONS

79       None.
80

SEE ALSO

82       The Base Definitions volume of POSIX.1‐2017, <unistd.h>
83
85       Portions of this text are reprinted and reproduced in  electronic  form
86       from  IEEE Std 1003.1-2017, Standard for Information Technology -- Por‐
87       table Operating System Interface (POSIX), The Open Group Base  Specifi‐
88       cations  Issue  7, 2018 Edition, Copyright (C) 2018 by the Institute of
89       Electrical and Electronics Engineers, Inc and The Open Group.   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.opengroup.org/unix/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                  2017                          TTYNAME(3P)
Impressum