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

ctermid.3p (4584B)


  1. '\" et
  2. .TH CTERMID "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. ctermid
  12. \(em generate a pathname for the controlling terminal
  13. .SH SYNOPSIS
  14. .LP
  15. .nf
  16. #include <stdio.h>
  17. .P
  18. char *ctermid(char *\fIs\fP);
  19. .fi
  20. .SH DESCRIPTION
  21. The
  22. \fIctermid\fR()
  23. function shall generate a string that, when used as a pathname,
  24. refers to the current controlling terminal for the current process. If
  25. \fIctermid\fR()
  26. returns a pathname, access to the file is not guaranteed.
  27. .P
  28. The
  29. \fIctermid\fR()
  30. function need not be thread-safe if called with a NULL parameter.
  31. .SH "RETURN VALUE"
  32. If
  33. .IR s
  34. is a null pointer, the string shall be generated in an area that may be
  35. static, the address of which shall be returned. The application shall
  36. not modify the string returned. The returned pointer might be invalidated
  37. or the string content might be overwritten by a subsequent call to
  38. \fIctermid\fR().
  39. The returned pointer might also be invalidated if the calling thread
  40. is terminated.
  41. If
  42. .IR s
  43. is not a null pointer,
  44. .IR s
  45. is assumed to point to a character array of at least L_ctermid bytes;
  46. the string is placed in this array and the value of
  47. .IR s
  48. shall be returned. The symbolic constant L_ctermid is defined in
  49. .IR <stdio.h> ,
  50. and shall have a value greater than 0.
  51. .P
  52. The
  53. \fIctermid\fR()
  54. function shall return an empty string if the pathname that would refer
  55. to the controlling terminal cannot be determined, or if the function is
  56. unsuccessful.
  57. .SH ERRORS
  58. No errors are defined.
  59. .LP
  60. .IR "The following sections are informative."
  61. .SH EXAMPLES
  62. .SS "Determining the Controlling Terminal for the Current Process"
  63. .P
  64. The following example returns a pointer to a string that identifies the
  65. controlling terminal for the current process. The pathname for the
  66. terminal is stored in the array pointed to by the
  67. .IR ptr
  68. argument, which has a size of L_ctermid bytes, as indicated by the
  69. .IR term
  70. argument.
  71. .sp
  72. .RS 4
  73. .nf
  74. #include <stdio.h>
  75. \&...
  76. char term[L_ctermid];
  77. char *ptr;
  78. .P
  79. ptr = ctermid(term);
  80. .fi
  81. .P
  82. .RE
  83. .SH "APPLICATION USAGE"
  84. The difference between
  85. \fIctermid\fR()
  86. and
  87. \fIttyname\fR()
  88. is that
  89. \fIttyname\fR()
  90. must be handed a file descriptor and return a path of the terminal
  91. associated with that file descriptor, while
  92. \fIctermid\fR()
  93. returns a string (such as
  94. .BR \(dq/dev/tty\(dq )
  95. that refers to the current controlling terminal if used as a
  96. pathname.
  97. .SH RATIONALE
  98. L_ctermid
  99. must be defined appropriately for a given implementation and must be
  100. greater than zero so that array declarations using it are accepted by
  101. the compiler. The value includes the terminating null byte.
  102. .P
  103. Conforming applications that use multiple threads cannot call
  104. \fIctermid\fR()
  105. with NULL as the parameter. If
  106. .IR s
  107. is not NULL, the
  108. \fIctermid\fR()
  109. function generates a string that, when used as a pathname, refers to
  110. the current controlling terminal for the current process. If
  111. .IR s
  112. is NULL, the return value of
  113. \fIctermid\fR()
  114. is undefined.
  115. .P
  116. There is no additional burden on the programmer\(emchanging to use a
  117. hypothetical thread-safe version of
  118. \fIctermid\fR()
  119. along with allocating a buffer is more of a burden than merely
  120. allocating a buffer. Application code should not assume that the
  121. returned string is short, as some implementations have more than two
  122. pathname components before reaching a logical device name.
  123. .SH "FUTURE DIRECTIONS"
  124. None.
  125. .SH "SEE ALSO"
  126. .IR "\fIttyname\fR\^(\|)"
  127. .P
  128. The Base Definitions volume of POSIX.1\(hy2017,
  129. .IR "\fB<stdio.h>\fP"
  130. .\"
  131. .SH COPYRIGHT
  132. Portions of this text are reprinted and reproduced in electronic form
  133. from IEEE Std 1003.1-2017, Standard for Information Technology
  134. -- Portable Operating System Interface (POSIX), The Open Group Base
  135. Specifications Issue 7, 2018 Edition,
  136. Copyright (C) 2018 by the Institute of
  137. Electrical and Electronics Engineers, Inc and The Open Group.
  138. In the event of any discrepancy between this version and the original IEEE and
  139. The Open Group Standard, the original IEEE and The Open Group Standard
  140. is the referee document. The original Standard can be obtained online at
  141. http://www.opengroup.org/unix/online.html .
  142. .PP
  143. Any typographical or formatting errors that appear
  144. in this page are most likely
  145. to have been introduced during the conversion of the source files to
  146. man page format. To report such errors, see
  147. https://www.kernel.org/doc/man-pages/reporting_bugs.html .