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

tcsetattr.3p (8061B)


  1. '\" et
  2. .TH TCSETATTR "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. tcsetattr
  12. \(em set the parameters associated with the terminal
  13. .SH SYNOPSIS
  14. .LP
  15. .nf
  16. #include <termios.h>
  17. .P
  18. int tcsetattr(int \fIfildes\fP, int \fIoptional_actions\fP,
  19. const struct termios *\fItermios_p\fP);
  20. .fi
  21. .SH DESCRIPTION
  22. The
  23. \fItcsetattr\fR()
  24. function shall set the parameters associated with the terminal referred
  25. to by the open file descriptor
  26. .IR fildes
  27. (an open file descriptor associated with a terminal) from the
  28. .BR termios
  29. structure referenced by
  30. .IR termios_p
  31. as follows:
  32. .IP " *" 4
  33. If
  34. .IR optional_actions
  35. is TCSANOW, the change shall occur immediately.
  36. .IP " *" 4
  37. If
  38. .IR optional_actions
  39. is TCSADRAIN, the change shall occur after all output written to
  40. .IR fildes
  41. is transmitted. This function should be used when changing parameters
  42. that affect output.
  43. .IP " *" 4
  44. If
  45. .IR optional_actions
  46. is TCSAFLUSH, the change shall occur after all output written to
  47. .IR fildes
  48. is transmitted, and all input so far received but not read shall be
  49. discarded before the change is made.
  50. .P
  51. If the output baud rate stored in the
  52. .BR termios
  53. structure pointed to by
  54. .IR termios_p
  55. is the zero baud rate, B0, the modem control lines shall no longer
  56. be asserted. Normally, this shall disconnect the line.
  57. .P
  58. If the input baud rate stored in the
  59. .BR termios
  60. structure pointed to by
  61. .IR termios_p
  62. is 0, the input baud rate given to the hardware is the same as the
  63. output baud rate stored in the
  64. .BR termios
  65. structure.
  66. .P
  67. The
  68. \fItcsetattr\fR()
  69. function shall return successfully if it was able to perform any of the
  70. requested actions, even if some of the requested actions could not be
  71. performed. It shall set all the attributes that the implementation
  72. supports as requested and leave all the attributes not supported by
  73. the implementation unchanged. If no part of the request can be honored,
  74. it shall return \-1 and set
  75. .IR errno
  76. to
  77. .BR [EINVAL] .
  78. If the input and output baud rates differ and are a combination that is
  79. not supported, neither baud rate shall be changed. A subsequent call to
  80. \fItcgetattr\fR()
  81. shall return the actual state of the terminal device (reflecting both
  82. the changes made and not made in the previous
  83. \fItcsetattr\fR()
  84. call). The
  85. \fItcsetattr\fR()
  86. function shall not change the values found in the
  87. .BR termios
  88. structure under any circumstances.
  89. .P
  90. The effect of
  91. \fItcsetattr\fR()
  92. is undefined if the value of the
  93. .BR termios
  94. structure pointed to by
  95. .IR termios_p
  96. was not derived from the result of a call to
  97. \fItcgetattr\fR()
  98. on
  99. .IR fildes ;
  100. an application should modify only fields and flags defined by this volume of POSIX.1\(hy2017
  101. between the call to
  102. \fItcgetattr\fR()
  103. and
  104. \fItcsetattr\fR(),
  105. leaving all other fields and flags unmodified.
  106. .P
  107. No actions defined by this volume of POSIX.1\(hy2017, other than a call to
  108. \fItcsetattr\fR(),
  109. a close of the last file descriptor in the system associated with this
  110. terminal device, or an open of the first file descriptor in the system
  111. associated with this terminal device (using the O_TTY_INIT flag if it
  112. is non-zero and the device is not a pseudo-terminal), shall cause any
  113. of the terminal attributes defined by this volume of POSIX.1\(hy2017 to change.
  114. .P
  115. If
  116. \fItcsetattr\fR()
  117. is called from a process which is a member of a background process
  118. group on a
  119. .IR fildes
  120. associated with its controlling terminal:
  121. .IP " *" 4
  122. If the calling thread is blocking SIGTTOU signals or the process is
  123. ignoring SIGTTOU signals, the operation completes normally and no signal
  124. is sent.
  125. .IP " *" 4
  126. Otherwise, a SIGTTOU signal shall be sent to the process group.
  127. .SH "RETURN VALUE"
  128. Upon successful completion, 0 shall be returned. Otherwise,
  129. \-1 shall be returned and
  130. .IR errno
  131. set to indicate the error.
  132. .SH ERRORS
  133. The
  134. \fItcsetattr\fR()
  135. function shall fail if:
  136. .TP
  137. .BR EBADF
  138. The
  139. .IR fildes
  140. argument is not a valid file descriptor.
  141. .TP
  142. .BR EINTR
  143. A signal interrupted
  144. \fItcsetattr\fR().
  145. .TP
  146. .BR EINVAL
  147. The
  148. .IR optional_actions
  149. argument is not a supported value, or an attempt was made to change an
  150. attribute represented in the
  151. .BR termios
  152. structure to an unsupported value.
  153. .TP
  154. .BR EIO
  155. The process group of the writing process is orphaned, the calling thread
  156. is not blocking SIGTTOU, and the process is not ignoring SIGTTOU.
  157. .TP
  158. .BR ENOTTY
  159. The file associated with
  160. .IR fildes
  161. is not a terminal.
  162. .LP
  163. .IR "The following sections are informative."
  164. .SH EXAMPLES
  165. None.
  166. .SH "APPLICATION USAGE"
  167. If trying to change baud rates, applications should call
  168. \fItcsetattr\fR()
  169. then call
  170. \fItcgetattr\fR()
  171. in order to determine what baud rates were actually selected.
  172. .P
  173. In general, there are two reasons for an application to change the
  174. parameters associated with a terminal device:
  175. .IP " 1." 4
  176. The device already has working parameter settings but the application
  177. needs a different behavior, such as non-canonical mode instead of
  178. canonical mode. The application sets (or clears) only a few flags or
  179. .IR c_cc [\^]
  180. values. Typically, the terminal device in this case is either the
  181. controlling terminal for the process or a pseudo-terminal.
  182. .IP " 2." 4
  183. The device is a modem or similar piece of equipment connected by a serial
  184. line, and it was not open before the application opened it. In this case,
  185. the application needs to initialize all of the parameter settings ``from
  186. scratch''. However, since the
  187. .BR termios
  188. structure may include both standard and non-standard parameters, the
  189. application cannot just initialize the whole structure in an arbitrary
  190. way (e.g., using
  191. \fImemset\fR())
  192. as this may cause some of the non-standard parameters to be set
  193. incorrectly, resulting in non-conforming behavior of the terminal
  194. device. Conversely, the application cannot just set the standard
  195. parameters, assuming that the non-standard parameters will already have
  196. suitable values, as the device might previously have been used with
  197. non-conforming parameter settings (and some implementations retain the
  198. settings from one use to the next). The solution is to open the terminal
  199. device using the O_TTY_INIT flag to initialize the terminal device to
  200. have conforming parameter settings, obtain those settings using
  201. \fItcgetattr\fR(),
  202. and then set all of the standard parameters to the desired settings.
  203. .SH RATIONALE
  204. The
  205. \fItcsetattr\fR()
  206. function can be interrupted in the following situations:
  207. .IP " *" 4
  208. It is interrupted while waiting for output to drain.
  209. .IP " *" 4
  210. It is called from a process in a background process group and SIGTTOU
  211. is caught.
  212. .P
  213. See also the RATIONALE section in
  214. .IR "\fItcgetattr\fR\^(\|)".
  215. .SH "FUTURE DIRECTIONS"
  216. Using an input baud rate of 0 to set the input rate equal to the output
  217. rate may not necessarily be supported in a future version of this volume of POSIX.1\(hy2017.
  218. .SH "SEE ALSO"
  219. .IR "\fIcfgetispeed\fR\^(\|)",
  220. .IR "\fItcgetattr\fR\^(\|)"
  221. .P
  222. The Base Definitions volume of POSIX.1\(hy2017,
  223. .IR "Chapter 11" ", " "General Terminal Interface",
  224. .IR "\fB<termios.h>\fP"
  225. .\"
  226. .SH COPYRIGHT
  227. Portions of this text are reprinted and reproduced in electronic form
  228. from IEEE Std 1003.1-2017, Standard for Information Technology
  229. -- Portable Operating System Interface (POSIX), The Open Group Base
  230. Specifications Issue 7, 2018 Edition,
  231. Copyright (C) 2018 by the Institute of
  232. Electrical and Electronics Engineers, Inc and The Open Group.
  233. In the event of any discrepancy between this version and the original IEEE and
  234. The Open Group Standard, the original IEEE and The Open Group Standard
  235. is the referee document. The original Standard can be obtained online at
  236. http://www.opengroup.org/unix/online.html .
  237. .PP
  238. Any typographical or formatting errors that appear
  239. in this page are most likely
  240. to have been introduced during the conversion of the source files to
  241. man page format. To report such errors, see
  242. https://www.kernel.org/doc/man-pages/reporting_bugs.html .