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

tcgetattr.3p (4703B)


  1. '\" et
  2. .TH TCGETATTR "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. tcgetattr
  12. \(em get the parameters associated with the terminal
  13. .SH SYNOPSIS
  14. .LP
  15. .nf
  16. #include <termios.h>
  17. .P
  18. int tcgetattr(int \fIfildes\fP, struct termios *\fItermios_p\fP);
  19. .fi
  20. .SH DESCRIPTION
  21. The
  22. \fItcgetattr\fR()
  23. function shall get the parameters associated with the terminal referred
  24. to by
  25. .IR fildes
  26. and store them in the
  27. .BR termios
  28. structure referenced by
  29. .IR termios_p .
  30. The
  31. .IR fildes
  32. argument is an open file descriptor associated with a terminal.
  33. .P
  34. The
  35. .IR termios_p
  36. argument is a pointer to a
  37. .BR termios
  38. structure.
  39. .P
  40. The
  41. \fItcgetattr\fR()
  42. operation is allowed from any process.
  43. .P
  44. If the terminal device supports different input and output baud rates,
  45. the baud rates stored in the
  46. .BR termios
  47. structure returned by
  48. \fItcgetattr\fR()
  49. shall reflect the actual baud rates, even if they are equal. If
  50. differing baud rates are not supported, the rate returned as the output
  51. baud rate shall be the actual baud rate. If the terminal device does
  52. not support split baud rates, the input baud rate stored in the
  53. .BR termios
  54. structure shall be the output rate (as one of the symbolic values).
  55. .SH "RETURN VALUE"
  56. Upon successful completion, 0 shall be returned. Otherwise, \-1
  57. shall be returned and
  58. .IR errno
  59. set to indicate the error.
  60. .SH ERRORS
  61. The
  62. \fItcgetattr\fR()
  63. function shall fail if:
  64. .TP
  65. .BR EBADF
  66. The
  67. .IR fildes
  68. argument is not a valid file descriptor.
  69. .TP
  70. .BR ENOTTY
  71. The file associated with
  72. .IR fildes
  73. is not a terminal.
  74. .LP
  75. .IR "The following sections are informative."
  76. .SH EXAMPLES
  77. None.
  78. .SH "APPLICATION USAGE"
  79. None.
  80. .SH RATIONALE
  81. Care must be taken when changing the terminal attributes. Applications
  82. should always do a
  83. \fItcgetattr\fR(),
  84. save the
  85. .BR termios
  86. structure values returned, and then do a
  87. \fItcsetattr\fR(),
  88. changing only the necessary fields. The application should use the
  89. values saved from the
  90. \fItcgetattr\fR()
  91. to reset the terminal state whenever it is done with the terminal.
  92. This is necessary because terminal attributes apply to the underlying
  93. port and not to each individual open instance; that is, all processes
  94. that have used the terminal see the latest attribute changes.
  95. .P
  96. A program that uses these functions should be written to catch all
  97. signals and take other appropriate actions to ensure that when the
  98. program terminates, whether planned or not, the terminal device's state
  99. is restored to its original state.
  100. .P
  101. Existing practice dealing with error returns when only part of a
  102. request can be honored is based on calls to the
  103. \fIioctl\fR()
  104. function. In historical BSD and System V implementations,
  105. the corresponding
  106. \fIioctl\fR()
  107. returns zero if the requested actions were semantically correct, even
  108. if some of the requested changes could not be made. Many existing
  109. applications assume this behavior and would no longer work correctly if
  110. the return value were changed from zero to \-1 in this case.
  111. .P
  112. Note that either specification has a problem. When zero is returned,
  113. it implies everything succeeded even if some of the changes were not
  114. made. When \-1 is returned, it implies everything failed even though
  115. some of the changes were made.
  116. .P
  117. Applications that need all of the requested changes made to work
  118. properly should follow
  119. \fItcsetattr\fR()
  120. with a call to
  121. \fItcgetattr\fR()
  122. and compare the appropriate field values.
  123. .SH "FUTURE DIRECTIONS"
  124. None.
  125. .SH "SEE ALSO"
  126. .IR "\fItcsetattr\fR\^(\|)"
  127. .P
  128. The Base Definitions volume of POSIX.1\(hy2017,
  129. .IR "Chapter 11" ", " "General Terminal Interface",
  130. .IR "\fB<termios.h>\fP"
  131. .\"
  132. .SH COPYRIGHT
  133. Portions of this text are reprinted and reproduced in electronic form
  134. from IEEE Std 1003.1-2017, Standard for Information Technology
  135. -- Portable Operating System Interface (POSIX), The Open Group Base
  136. Specifications Issue 7, 2018 Edition,
  137. Copyright (C) 2018 by the Institute of
  138. Electrical and Electronics Engineers, Inc and The Open Group.
  139. In the event of any discrepancy between this version and the original IEEE and
  140. The Open Group Standard, the original IEEE and The Open Group Standard
  141. is the referee document. The original Standard can be obtained online at
  142. http://www.opengroup.org/unix/online.html .
  143. .PP
  144. Any typographical or formatting errors that appear
  145. in this page are most likely
  146. to have been introduced during the conversion of the source files to
  147. man page format. To report such errors, see
  148. https://www.kernel.org/doc/man-pages/reporting_bugs.html .