logo

oasis-root

Compiled tree of Oasis Linux based on own branch at <https://hacktivis.me/git/oasis/> git clone https://anongit.hacktivis.me/git/oasis-root.git

ttyname.3p (3781B)


  1. '\" et
  2. .TH TTYNAME "3P" 2017 "IEEE/The Open Group" "POSIX Programmer's Manual"
  3. .\"
  4. .SH PROLOG
  5. This manual page is part of the POSIX Programmer's Manual.
  6. The Linux implementation of this interface may differ (consult
  7. the corresponding Linux manual page for details of Linux behavior),
  8. or the interface may not be implemented on Linux.
  9. .\"
  10. .SH NAME
  11. ttyname,
  12. ttyname_r
  13. \(em find the pathname of a terminal
  14. .SH SYNOPSIS
  15. .LP
  16. .nf
  17. #include <unistd.h>
  18. .P
  19. char *ttyname(int \fIfildes\fP);
  20. int ttyname_r(int \fIfildes\fP, char *\fIname\fP, size_t \fInamesize\fP);
  21. .fi
  22. .SH DESCRIPTION
  23. The
  24. \fIttyname\fR()
  25. function shall return a pointer to a string containing a null-terminated
  26. pathname of the terminal associated with file descriptor
  27. .IR fildes .
  28. The application shall not modify the string returned. The returned
  29. pointer might be invalidated or the string content might be overwritten
  30. by a subsequent call to
  31. \fIttyname\fR().
  32. The returned pointer and the string content might also be invalidated
  33. if the calling thread is terminated.
  34. .P
  35. The
  36. \fIttyname\fR()
  37. function need not be thread-safe.
  38. .P
  39. The
  40. \fIttyname_r\fR()
  41. function shall store the null-terminated pathname of the terminal
  42. associated with the file descriptor
  43. .IR fildes
  44. in the character array referenced by
  45. .IR name .
  46. The array is
  47. .IR namesize
  48. characters long and should have space for the name and the terminating
  49. null character. The maximum length of the terminal name shall be
  50. {TTY_NAME_MAX}.
  51. .SH "RETURN VALUE"
  52. Upon successful completion,
  53. \fIttyname\fR()
  54. shall return a pointer to a string. Otherwise, a null pointer shall
  55. be returned and
  56. .IR errno
  57. set to indicate the error.
  58. .P
  59. If successful, the
  60. \fIttyname_r\fR()
  61. function shall return zero. Otherwise, an error number shall be
  62. returned to indicate the error.
  63. .SH ERRORS
  64. The
  65. \fIttyname\fR()
  66. function may fail if:
  67. .TP
  68. .BR EBADF
  69. The
  70. .IR fildes
  71. argument is not a valid file descriptor.
  72. .TP
  73. .BR ENOTTY
  74. The file associated with the
  75. .IR fildes
  76. argument is not a terminal.
  77. .P
  78. The
  79. \fIttyname_r\fR()
  80. function may fail if:
  81. .TP
  82. .BR EBADF
  83. The
  84. .IR fildes
  85. argument is not a valid file descriptor.
  86. .TP
  87. .BR ENOTTY
  88. The file associated with the
  89. .IR fildes
  90. argument is not a terminal.
  91. .TP
  92. .BR ERANGE
  93. The value of
  94. .IR namesize
  95. is smaller than the length of the string to be returned including the
  96. terminating null character.
  97. .LP
  98. .IR "The following sections are informative."
  99. .SH EXAMPLES
  100. None.
  101. .SH "APPLICATION USAGE"
  102. None.
  103. .SH RATIONALE
  104. The term ``terminal'' is used instead of the historical term
  105. ``terminal device'' in order to avoid a reference to an undefined
  106. term.
  107. .P
  108. The thread-safe version places the terminal name in a user-supplied
  109. buffer and returns a non-zero value if it fails. The non-thread-safe
  110. version may return the name in a static data area that may be
  111. overwritten by each call.
  112. .SH "FUTURE DIRECTIONS"
  113. None.
  114. .SH "SEE ALSO"
  115. The Base Definitions volume of POSIX.1\(hy2017,
  116. .IR "\fB<unistd.h>\fP"
  117. .\"
  118. .SH COPYRIGHT
  119. Portions of this text are reprinted and reproduced in electronic form
  120. from IEEE Std 1003.1-2017, Standard for Information Technology
  121. -- Portable Operating System Interface (POSIX), The Open Group Base
  122. Specifications Issue 7, 2018 Edition,
  123. Copyright (C) 2018 by the Institute of
  124. Electrical and Electronics Engineers, Inc and The Open Group.
  125. In the event of any discrepancy between this version and the original IEEE and
  126. The Open Group Standard, the original IEEE and The Open Group Standard
  127. is the referee document. The original Standard can be obtained online at
  128. http://www.opengroup.org/unix/online.html .
  129. .PP
  130. Any typographical or formatting errors that appear
  131. in this page are most likely
  132. to have been introduced during the conversion of the source files to
  133. man page format. To report such errors, see
  134. https://www.kernel.org/doc/man-pages/reporting_bugs.html .