Print this page
10560 Convert termio(7I) to mandoc
   1 '\" te
   2 .\" Copyright (c) 2005, Sun Microsystems, Inc.  All Rights Reserved.
   3 .\" Copyright (c) 2014, Joyent, Inc.  All Rights Reserved.
   4 .\" Copyright 1989 AT&T
   5 .\" The contents of this file are subject to the terms of the Common Development and Distribution License (the "License").  You may not use this file except in compliance with the License.
   6 .\" You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE or http://www.opensolaris.org/os/licensing.  See the License for the specific language governing permissions and limitations under the License.
   7 .\" When distributing Covered Code, include this CDDL HEADER in each file and include the License file at usr/src/OPENSOLARIS.LICENSE.  If applicable, add the following below this CDDL HEADER, with the fields enclosed by brackets "[]" replaced with your own identifying information: Portions Copyright [yyyy] [name of copyright owner]
   8 .TH TERMIO 7I "Dec 30, 2016"
   9 .SH NAME
  10 termio \- general terminal interface
  11 .SH SYNOPSIS
  12 .LP
  13 .nf
  14 #include <termio.h>
  15 
  16 \fB\fR\fBioctl\fR(\fBint\fR \fIfildes\fR, \fBint\fR \fIrequest\fR, \fBstruct termio *\fR\fIarg\fR);
  17 .fi
  18 
  19 .LP
  20 .nf
  21 \fB\fR\fBioctl\fR(\fBint\fR \fIfildes\fR, \fBint\fR \fIrequest\fR, \fBint\fR \fIarg\fR);
  22 .fi
  23 
  24 .LP
  25 .nf
  26 #include <termios.h>
  27 
  28 \fB\fR\fBioctl\fR(\fBint\fR \fIfildes\fR, \fBint\fR \fIrequest\fR, \fBstruct termios *\fR\fIarg\fR);
  29 .fi
  30 
  31 .SH DESCRIPTION
  32 .LP
  33 This release supports a general interface for asynchronous communications ports
  34 that is hardware-independent. The user interface to this functionality is using
  35 function calls (the preferred interface) described in \fBtermios\fR(3C) or
  36 \fBioctl\fR commands described in this section. This section also discusses the





  37 common features of the  terminal subsystem which are relevant with both user
  38 interfaces.
  39 .sp
  40 .LP
  41 When a terminal file is opened, it normally causes the process to wait until a
  42 connection is established. In practice, user programs seldom open terminal

  43 files; they are opened by the system and become a user's standard input,
  44 output, and error files. The first terminal file opened by the session leader

  45 that is not already associated with a session becomes the controlling terminal
  46 for that session. The controlling terminal plays a special role in handling
  47 quit and interrupt signals, as discussed below. The controlling terminal is
  48 inherited by a child process during a \fBfork\fR(2). A process can break this
  49 association by changing its session using \fBsetsid()\fR (see \fBsetsid\fR(2)).
  50 .sp
  51 .LP




  52 A terminal associated with one of these files ordinarily operates in
  53 full-duplex mode. Characters may be typed at any time, even while output is

  54 occurring, and are only lost when the character input buffers of the system
  55 become completely full, which is rare. For example, the number of characters in
  56 the line discipline buffer may exceed {\fBMAX_CANON\fR}  and  \fBIMAXBEL\fR
  57 (see below) is not set, or the user may accumulate { \fBMAX_INPUT\fR} number of
  58 input characters that have not yet been read by some program. When the input






  59 limit is reached, all the characters saved in the buffer up to that point are
  60 thrown away without notice.
  61 .SS "Session Management (Job Control)"
  62 .LP
  63 A control terminal will distinguish one of the process groups in the session
  64 associated with it to be the  foreground process group. All other process
  65 groups in the session are designated as background process groups. This
  66 foreground process group plays a special role in handling signal-generating
  67 input characters, as discussed below. By default, when a controlling terminal


  68 is allocated, the controlling process's process group is assigned  as
  69 foreground process group.
  70 .sp
  71 .LP
  72 Background process groups in the controlling process's session are subject to a
  73 job control line discipline when they attempt to access their controlling
  74 terminal. Process groups can be sent signals that will cause them to stop,
  75 unless they have made other arrangements. An exception is made for members of


  76 orphaned process groups.
  77 .sp
  78 .LP
  79 An orphaned process group is one where the process group (see \fBgetpgid\fR(2))
  80 has no members with a parent in a different process group but sharing the same
  81 controlling terminal. When a member of an orphaned process group attempts to

  82 access its controlling terminal, EIO is returned because there would be no way
  83 to restart the process if it were stopped on one of these signals.
  84 .sp
  85 .LP
  86 If a member of a background process group attempts to read its controlling
  87 terminal, its process group will be sent a  \fBSIGTTIN\fR signal, which will
  88 normally cause the members of that process group to stop. If, however, the
  89 process is ignoring or holding \fBSIGTTIN\fR, or is a member of an orphaned
  90 process group, the read will fail with \fBerrno\fR set to  \fBEIO\fR, and no
  91 signal is sent.
  92 .sp
  93 .LP







  94 If a member of a background process group attempts to write its controlling
  95 terminal and the \fBTOSTOP\fR bit is set in the \fBc_lflag\fR field, its
  96 process group is sent a \fBSIGTTOU\fR signal, which will normally cause the
  97 members of that process group to stop. If, however, the process is ignoring or
  98 holding \fBSIGTTOU\fR, the write will succeed. If the process is not ignoring
  99 or holding \fBSIGTTOU\fR and is a member of an orphaned process group, the
 100 write will fail with  \fBerrno\fR set to  \fBEIO\fR, and no signal will be
 101 sent.
 102 .sp
 103 .LP
 104 If \fBTOSTOP\fR is set and a member of a background process group attempts  to
 105 \fBioctl\fR its controlling terminal, and that \fBioctl\fR will modify terminal
 106 parameters (for example, \fBTCSETA\fR, \fBTCSETAW\fR, \fBTCSETAF\fR, or
 107 \fBTIOCSPGRP)\fR, its process group will be sent a \fBSIGTTOU\fR signal, which
 108 will normally cause the members of that process group to stop. If, however, the
 109 process is ignoring or holding \fBSIGTTOU\fR, the ioctl will succeed. If the
 110 process is not ignoring or holding \fBSIGTTOU\fR and is a member of an orphaned
 111 process group, the write will fail with  \fBerrno\fR set to \fBEIO\fR, and no
 112 signal will be sent.
 113 .SS "Canonical Mode Input Processing"
 114 .LP
 115 Normally, terminal input is processed in units of lines. A line is delimited by
 116 a newline (\fBASCII LF\fR) character, an end-of-file (\fBASCII EOT\fR)
 117 character, or an end-of-line character. This means that a program attempting to
 118 read will block until an entire line has been typed. Also, no matter how many







































 119 characters are requested in the read call, at most one line will be returned.
 120 It is not necessary, however, to read a whole line at once; any number of
 121 characters may be requested in a read, even one, without losing information.
 122 .sp
 123 .LP
 124 During input, erase, erase2, and kill processing is normally done. The
 125 \fBERASE\fR and \fBERASE2\fR character (by default, the character \fBDEL\fR for \fBERASE\fR and \fBControl-h\fR for \fBERASE2\fR) erases the last character
 126 typed. The \fBWERASE\fR character (the character  \fBControl-w\fR) erases the















 127 last "word" typed in the current input line (but not any preceding spaces or
 128 tabs). A "word" is defined as a sequence of non-blank characters, with tabs
 129 counted as blanks. None of \fBERASE\fR or \fBERASE2\fR or \fBWERASE\fR will
 130 erase beyond the beginning of the line.  The \fBKILL\fR character (by default,
 131 the character \fBNAK\fR) kills (deletes) the entire input line, and optionally
 132 outputs a newline character. All these characters operate on a key stroke basis,
 133 independent of any backspacing or tabbing that may have been done. The
 134 \fBREPRINT\fR character (the character Control-r) prints a newline followed by
 135 all characters that have not been read. Reprinting also occurs automatically if


















 136 characters that would normally be erased from the screen are fouled by program
 137 output. The characters are reprinted as if they were being echoed;
 138 consequencely, if \fBECHO\fR is not set, they are not printed.
 139 .sp
 140 .LP
 141 The \fBERASE\fR, \fBERASE2\fR, and \fBKILL\fR characters may be entered
 142 literally by preceding them with the escape character. In this case, the
 143 escape character is not read.  The erase, erase2, and kill characters may be
 144 changed.
 145 .SS "Non-canonical Mode Input Processing"
 146 .LP





 147 In non-canonical mode input processing, input characters are not assembled into
 148 lines, and erase and kill processing does not occur. The \fBMIN\fR and
 149 \fBTIME\fR values are used to determine how to process the characters received.
 150 .sp
 151 .LP
 152 \fBMIN\fR represents the minimum number of characters that should be received




 153 when the read is satisfied (that is, when the characters are returned to the
 154 user). \fBTIME\fR is a timer of 0.10-second granularity that is used to timeout
 155 bursty and short-term data transmissions. The four possible values for
 156 \fBMIN\fR and \fBTIME\fR and their interactions are described below.
 157 .sp
 158 .ne 2
 159 .na
 160 \fBCase A: MIN > 0, TIME > 0\fR
 161 .ad
 162 .RS 29n
 163 In this case, \fBTIME\fR serves as an intercharacter timer and is activated
 164 after the first character is received.  Since it is an intercharacter timer, it
 165 is reset after a character is received. The interaction between \fBMIN\fR and
 166 \fBTIME\fR is as follows: as soon as one character is received, the
 167 intercharacter timer is started. If  \fBMIN\fR characters are received before












 168 the intercharacter timer expires (note that the timer is reset upon receipt of
 169 each character), the read is satisfied.  If the timer expires before \fBMIN\fR


 170 characters are received, the characters received to that point are returned to
 171 the user. Note that if  \fBTIME\fR expires, at least one character will be



 172 returned because  the timer would not have been enabled unless a character was
 173 received. In this case (MIN > 0, TIME > 0), the read sleeps until the \fBMIN\fR
 174 and \fBTIME\fR mechanisms are activated by the receipt of the first character.




 175 If the number of characters read is less than the number of characters
 176 available, the timer is not reactivated and the subsequent read is satisfied
 177 immediately.
 178 .RE
 179 
 180 .sp
 181 .ne 2
 182 .na
 183 \fBCase B: MIN > 0, TIME = 0\fR
 184 .ad
 185 .RS 29n
 186 In this case, since the value of \fBTIME\fR is zero, the timer plays no role
 187 and only \fBMIN\fR is significant.  A pending read is not satisfied until
 188 \fBMIN\fR characters are received (the pending read sleeps until  \fBMIN\fR
 189 characters are received). A program that uses this case to read record based
 190 terminal \fBI/O\fR may block indefinitely in the read operation.
 191 .RE
 192 
 193 .sp
 194 .ne 2
 195 .na
 196 \fBCase C: MIN = 0, TIME > 0\fR
 197 .ad
 198 .RS 29n
 199 In this case, since \fBMIN\fR = 0,  \fBTIME\fR no longer represents an
 200 intercharacter timer: it now serves as a read timer that is activated as soon
 201 as a \fBread\fR is done.  A read is satisfied as soon as a single character is
 202 received or the read timer expires. Note that, in this case, if the timer
 203 expires, no character is returned. If the timer does not expire, the only way
 204 the read can be satisfied is if a  character is received. In this case, the






 205 read will not block indefinitely waiting for a character; if no character is
 206 received within \fBTIME\fR *.10 seconds after the read is initiated, the read


 207 returns with zero characters.
 208 .RE
 209 
 210 .sp
 211 .ne 2
 212 .na
 213 \fBCase D: MIN = 0, TIME = 0\fR
 214 .ad
 215 .RS 29n
 216 In this case, return is immediate. The minimum of either the number of
 217 characters requested or the number of characters currently available is
 218 returned without waiting for more characters to be input.
 219 .RE
 220 
 221 .SS "Comparing Different Cases of MIN, TIME Interaction"
 222 .LP
 223 Some points to note about  \fBMIN\fR and  \fBTIME\fR :
 224 .RS +4
 225 .TP
 226 .ie t \(bu
 227 .el o
 228 In the following explanations, note that the interactions of \fBMIN\fR and
 229 \fBTIME\fR are not symmetric.  For example, when  \fBMIN\fR > 0 and  \fBTIME\fR
 230 = 0,  \fBTIME\fR has no effect. However, in the opposite case, where  \fBMIN\fR
 231 = 0 and \fBTIME\fR > 0, both  \fBMIN\fR and  \fBTIME\fR play a role in that
 232 \fBMIN\fR is satisfied with the receipt of a single character.
 233 .RE
 234 .RS +4
 235 .TP
 236 .ie t \(bu
 237 .el o
 238 Also note that in case A (\fBMIN\fR > 0, \fBTIME\fR > 0), \fBTIME\fR represents
 239 an intercharacter timer,  whereas in case C ( \fBMIN\fR = 0, \fBTIME\fR > 0),
 240 \fBTIME\fR represents a read timer.
 241 .RE
 242 .sp
 243 .LP
 244 These two points highlight the dual purpose of the  \fBMIN/TIME\fR feature.
 245 Cases A and B, where  \fBMIN\fR > 0, exist to handle burst mode activity (for































 246 example, file transfer programs), where a program would like to process at
 247 least \fBMIN\fR characters at a time. In case A, the intercharacter timer is



 248 activated by a user as a safety measure; in case B, the timer is turned off.
 249 .sp
 250 .LP
 251 Cases C and D exist to handle single character, timed transfers. These cases
 252 are readily adaptable to screen-based applications that need to know if a
 253 character is present in the input queue before refreshing the screen. In case

 254 C, the read is timed, whereas in case D, it is not.
 255 .sp
 256 .LP
 257 Another important note is that \fBMIN\fR is always just a minimum.  It does not
 258 denote a record length. For example, if a program does a read of 20 bytes,
 259 \fBMIN\fR is 10, and 25 characters are present, then 20 characters will be




 260 returned to the user.
 261 .SS "Writing Characters"
 262 .LP
 263 When one or more characters are written, they are transmitted to the terminal
 264 as soon as previously written characters have finished typing. Input characters
 265 are echoed as they are typed if echoing has been enabled. If a process produces


 266 characters more rapidly than they can be typed, it will be suspended when its
 267 output queue exceeds some limit. When the queue is drained down to some

 268 threshold, the program is resumed.
 269 .SS "Special Characters"
 270 .LP
 271 Certain characters have special functions on input. These functions and their
 272 default character values are summarized as follows:
 273 .sp
 274 .ne 2
 275 .na
 276 \fB\fBINTR\fR\fR
 277 .ad
 278 .RS 11n
 279 (Control-c or \fBASCII ETX\fR) generates a \fBSIGINT\fR signal. \fBSIGINT\fR is
 280 sent to all foreground processes associated with the controlling terminal.
 281 Normally, each such process is forced to terminate, but arrangements may be
 282 made either to ignore the signal or to receive a trap to an agreed upon
 283 location. (See  \fBsignal.h\fR(3HEAD)).
 284 .RE
 285 
 286 .sp
 287 .ne 2
 288 .na
 289 \fB\fBQUIT\fR\fR
 290 .ad
 291 .RS 11n
 292 (Control-| or \fBASCII FS\fR) generates a \fBSIGQUIT\fR signal.  Its treatment
 293 is identical to the interrupt signal except that, unless a receiving process
 294 has made other arrangements, it will not only be terminated but a core image
 295 file (called  \fBcore\fR) will be created in the current working directory.
 296 .RE
 297 
 298 .sp
 299 .ne 2
 300 .na
 301 \fB\fBERASE\fR\fR
 302 .ad
 303 .RS 11n
 304 (DEL) erases the preceding character. It does not erase beyond
 305 the start of a line, as delimited by a \fBNL\fR, \fBEOF\fR, \fBEOL\fR, or
 306 \fBEOL2\fR character.
 307 .RE
 308 
 309 .sp
 310 .ne 2
 311 .na
 312 \fB\fBERASE2\fR\fR
 313 .ad
 314 .RS 11n
 315 (Control-h or \fBASCII BS\fR) erases the preceding character, with behaviour
 316 identical to that of ERASE.
 317 .RE
 318 
 319 .sp
 320 .ne 2
 321 .na
 322 \fB\fBWERASE\fR\fR
 323 .ad
 324 .RS 11n
 325 (Control-w or \fBASCII ETX\fR) erases the preceding "word". It does not erase
 326 beyond the start of a line, as delimited by a \fBNL\fR, \fBEOF\fR, \fBEOL\fR,
 327 or \fBEOL2\fR character.
 328 .RE
 329 
 330 .sp
 331 .ne 2
 332 .na
 333 \fB\fBKILL\fR\fR
 334 .ad
 335 .RS 11n
 336 (Control-u or \fBASCII NAK\fR) deletes the entire line, as delimited by a
 337 \fBNL\fR, \fBEOF\fR, \fBEOL\fR, or \fBEOL2\fR character.
 338 .RE
 339 
 340 .sp
 341 .ne 2
 342 .na
 343 \fB\fBREPRINT\fR\fR
 344 .ad
 345 .RS 11n
 346 (Control-r or \fBASCII DC2\fR) reprints all characters, preceded by a newline,
 347 that have not been read.
 348 .RE
 349 
 350 .sp
 351 .ne 2
 352 .na
 353 \fB\fBEOF\fR\fR
 354 .ad
 355 .RS 11n
 356 (Control-d or \fBASCII EOT\fR) may be used to generate an end-of-file  from a
 357 terminal. When received, all the characters waiting to be read are immediately
 358 passed to the program, without waiting for a newline, and the \fBEOF\fR is
 359 discarded.  Thus, if no characters are waiting (that is, the \fBEOF\fR occurred
 360 at the beginning of a line) zero characters are passed back, which is the
 361 standard end-of-file indication. Unless escaped, the \fBEOF\fR character is not
 362 echoed. Because \fBEOT\fR is the default \fBEOF\fR character, this prevents
 363 terminals that respond to \fBEOT\fR from hanging up.
 364 .RE
 365 
 366 .sp
 367 .ne 2
 368 .na
 369 \fB\fBNL\fR\fR
 370 .ad
 371 .RS 11n
 372 (ASCII LF) is the normal line delimiter. It cannot be changed or escaped.
 373 .RE
 374 
 375 .sp
 376 .ne 2
 377 .na
 378 \fB\fBEOL\fR\fR
 379 .ad
 380 .RS 11n
 381 (ASCII NULL) is an additional line delimiter, like \fBNL\fR . It is not
 382 normally used.
 383 .RE
 384 
 385 .sp
 386 .ne 2
 387 .na
 388 \fB\fBEOL2\fR\fR
 389 .ad
 390 .RS 11n
 391 is another additional line delimiter.
 392 .RE
 393 
 394 .sp
 395 .ne 2
 396 .na
 397 \fB\fBSWTCH\fR\fR
 398 .ad
 399 .RS 11n
 400 (Control-z or \fBASCII EM\fR) Header file symbols related to this special
 401 character are present for compatibility purposes only and the kernel takes no
 402 special action on matching SWTCH (except to discard the character).
 403 .RE
 404 
 405 .sp
 406 .ne 2
 407 .na
 408 \fB\fBSUSP\fR\fR
 409 .ad
 410 .RS 11n
 411 (Control-z or \fBASCII SUB\fR) generates a  \fBSIGTSTP\fR signal. \fBSIGTSTP\fR
 412 stops all processes in the foreground process group for that terminal.
 413 .RE
 414 
 415 .sp
 416 .ne 2
 417 .na
 418 \fB\fBDSUSP\fR\fR
 419 .ad
 420 .RS 11n
 421 (Control-y or \fBASCII EM\fR). It generates a \fBSIGTSTP\fR signal as
 422 \fBSUSP\fR does, but the signal is sent when a process in the foreground
 423 process group attempts to read the \fBDSUSP\fR character, rather than when it
 424 is typed.
 425 .RE
 426 
 427 .sp
 428 .ne 2
 429 .na
 430 \fB\fBSTOP\fR\fR
 431 .ad
 432 .RS 11n
 433 (Control-s or \fBASCII DC3\fR) can be used to suspend output temporarily. It is
 434 useful with \fBCRT\fR terminals to prevent output from disappearing before it
 435 can be read. While output is suspended, \fBSTOP\fR characters are ignored and
 436 not read.
 437 .RE
 438 
 439 .sp
 440 .ne 2
 441 .na
 442 \fB\fBSTART\fR\fR
 443 .ad
 444 .RS 11n
 445 (Control-q or \fBASCII DC1\fR) is used to resume output. Output has been
 446 suspended by a \fBSTOP\fR character.  While output is not suspended,
 447 \fBSTART\fR characters are ignored and not read.
 448 .RE
 449 
 450 .sp
 451 .ne 2
 452 .na
 453 \fB\fBDISCARD\fR\fR
 454 .ad
 455 .RS 11n
 456 (Control-o or \fBASCII SI\fR) causes subsequent output to be discarded. Output
 457 is discarded until another \fBDISCARD\fR character is typed, more input
 458 arrives, or the condition is cleared by a program.
 459 .RE
 460 
 461 .sp
 462 .ne 2
 463 .na
 464 \fB\fBSTATUS\fR\fR
 465 .ad
 466 .RS 11n
 467 (Control-t or \fBASCII DC4\fR) generates a \fBSIGINFO\fR signal. Processes with
 468 a handler will output status information when they receive \fBSIGINFO\fR, for
 469 example, \fBdd\fR(1M). If a process does not have a \fBSIGINFO\fR handler, the



 470 signal will be ignored.
 471 .RE
 472 
 473 .sp
 474 .ne 2
 475 .na
 476 \fB\fBLNEXT\fR\fR
 477 .ad
 478 .RS 11n
 479 (Control-v or \fBASCII SYN\fR) causes the special meaning of the next character
 480 to be ignored.  This works for all the special characters mentioned above. It
 481 allows characters to be input that would otherwise be interpreted by the system
 482 (for example \fBKILL, QUIT\fR).  The character values for \fBINTR\fR,
 483 \fBQUIT\fR, \fBERASE\fR, \fBERASE2\fR, \fBWERASE\fR, \fBKILL\fR, \fBREPRINT\fR,
 484 \fBEOF\fR, \fBEOL\fR, \fBEOL2\fR, \fBSWTCH\fR, \fBSUSP\fR, \fBDSUSP\fR,
 485 \fBSTOP\fR, \fBSTART\fR, \fBDISCARD\fR, \fBSTATUS\fR, and \fBLNEXT\fR may be
 486 changed to suit individual tastes. If the value of a special control character
 487 is _POSIX_VDISABLE (0), the function of that special control character is
 488 disabled.
 489 The \fBERASE\fR, \fBERASE2\fR, \fBKILL\fR, and \fBEOF\fR characters may be



























 490 escaped by a preceding backslash (\e) character, in which case no special
 491 function is done.
 492 Any of the special characters may be preceded by the \fBLNEXT\fR character, in


 493 which case no special function is done.
 494 .RE
 495 
 496 .SS "Modem Disconnect"
 497 .LP
 498 When a modem disconnect is detected, a \fBSIGHUP\fR signal is sent to the
 499 terminal's controlling process. Unless other arrangements have been made, these
 500 signals cause the process to terminate. If  \fBSIGHUP\fR is ignored or caught,




 501 any subsequent read returns with an end-of-file indication until the terminal
 502 is closed.
 503 .sp
 504 .LP
 505 If the controlling process is not in the  foreground process group of the
 506 terminal, a \fBSIGTSTP\fR is sent to the terminal's foreground process group.


 507 Unless other arrangements have been made, these signals cause the processes to
 508 stop.
 509 .sp
 510 .LP
 511 Processes in background process groups that attempt to access the controlling
 512 terminal after modem disconnect while the terminal is still allocated to the
 513 session will receive  appropriate \fBSIGTTOU\fR and  \fBSIGTTIN\fR signals.




 514 Unless other arrangements have  been made, this signal causes the processes to
 515 stop.
 516 .sp
 517 .LP
 518 The controlling terminal will remain in this state until it is  reinitialized
 519 with a successful open by the controlling process, or deallocated by the
 520 controlling process.
 521 .SS "Terminal Parameters"
 522 .LP
 523 The parameters that control the behavior of devices and modules providing the
 524 \fBtermios\fR interface are specified by the \fBtermios\fR structure defined by
 525 \fBtermios.h\fR. Several  \fBioctl\fR(2) system calls that fetch or change






 526 these parameters use this structure that contains the following members:
 527 .sp
 528 .in +2
 529 .nf
 530  tcflag_t c_iflag;  /* input modes */
 531         tcflag_t        c_oflag;  /* output modes */
 532         tcflag_t        c_cflag;  /* control modes */
 533         tcflag_t        c_lflag;  /* local modes */
 534         cc_t  c_cc[NCCS];  /* control chars */
 535 .fi
 536 .in -2
 537 
 538 .sp
 539 .LP
 540 The special control characters are defined by the array \fBc_cc\fR. The
 541 symbolic name \fBNCCS\fR is the size of the Control-character array and is also
 542 defined by \fB<termios.h>\fR\&. The relative positions, subscript names, and
 543 typical default values  for each function are as follows:
 544 .sp
 545 
 546 .sp
 547 .TS
 548 box;
 549 c | c | c
 550 l | l | l .
 551 Relative Position       Subscript Name  Typical Default Value
 552 _
 553 0       VINTR   ETX
 554 _
 555 1       VQUIT   FS
 556 _
 557 2       VERASE  DEL
 558 _
 559 3       VKILL   NAK
 560 _
 561 4       VEOF    EOT
 562 _
 563 5       VEOL    NUL
 564 _
 565 6       VEOL2   NUL
 566 _
 567 7       VWSTCH  NUL
 568 _
 569 8       VSTART  NUL
 570 _
 571 9       VSTOP   DC3
 572 _
 573 10      VSUSP   SUB
 574 _
 575 11      VDSUSP  EM
 576 _
 577 12      VREPRINT        DC2
 578 _
 579 13      VDISCARD        SI
 580 _
 581 14      VWERASE ETB
 582 _
 583 15      VLNEXT  SYN
 584 _
 585 16      VSTATUS DC4
 586 _
 587 17      VERASE2 BS
 588 _
 589 18-19   Reserved
 590 .TE
 591 
 592 .SS "Input Modes"
 593 .LP
 594 The \fBc_iflag\fR field describes the basic terminal input control:
 595 .sp
 596 .ne 2
 597 .na
 598 \fB\fBIGNBRK\fR\fR
 599 .ad
 600 .RS 11n
 601  Ignore break condition.
 602 .RE
 603 
 604 .sp
 605 .ne 2
 606 .na
 607 \fB\fBBRKINT\fR\fR
 608 .ad
 609 .RS 11n
 610 Signal interrupt on break.
 611 .RE
 612 
 613 .sp
 614 .ne 2
 615 .na
 616 \fB\fBIGNPAR\fR\fR
 617 .ad
 618 .RS 11n
 619 Ignore characters with parity errors.
 620 .RE
 621 
 622 .sp
 623 .ne 2
 624 .na
 625 \fB\fBPARMRK\fR\fR
 626 .ad
 627 .RS 11n
 628 Mark parity errors.
 629 .RE
 630 
 631 .sp
 632 .ne 2
 633 .na
 634 \fB\fBINPCK\fR\fR
 635 .ad
 636 .RS 11n
 637 Enable input parity check.
 638 .RE
 639 
 640 .sp
 641 .ne 2
 642 .na
 643 \fB\fBISTRIP\fR\fR
 644 .ad
 645 .RS 11n
 646 Strip character.
 647 .RE
 648 
 649 .sp
 650 .ne 2
 651 .na
 652 \fB\fBINLCR\fR\fR
 653 .ad
 654 .RS 11n
 655 Map NL to CR on input.
 656 .RE
 657 
 658 .sp
 659 .ne 2
 660 .na
 661 \fB\fBIGNCR\fR\fR
 662 .ad
 663 .RS 11n
 664 Ignore CR.
 665 .RE
 666 
 667 .sp
 668 .ne 2
 669 .na
 670 \fB\fBICRNL\fR\fR
 671 .ad
 672 .RS 11n
 673 Map CR to NL on input.
 674 .RE
 675 
 676 .sp
 677 .ne 2
 678 .na
 679 \fB\fBIUCLC\fR\fR
 680 .ad
 681 .RS 11n
 682 Map upper-case to lower-case on input.
 683 .RE
 684 
 685 .sp
 686 .ne 2
 687 .na
 688 \fB\fBIXON\fR\fR
 689 .ad
 690 .RS 11n
 691 Enable start/stop output control.
 692 .RE
 693 
 694 .sp
 695 .ne 2
 696 .na
 697 \fB\fBIXANY\fR\fR
 698 .ad
 699 .RS 11n
 700 Enable any character to restart output.
 701 .RE
 702 
 703 .sp
 704 .ne 2
 705 .na
 706 \fB\fBIXOFF\fR\fR
 707 .ad
 708 .RS 11n
 709 Enable start/stop input control.
 710 .RE
 711 
 712 .sp
 713 .ne 2
 714 .na
 715 \fB\fBIMAXBEL\fR\fR
 716 .ad
 717 .RS 11n
 718 Echo  \fBBEL\fR on input line too long.
 719 .RE
 720 
 721 .sp
 722 .LP
 723 If \fBIGNBRK\fR is set, a break condition (a character framing error with data
 724 all zeros) detected on input is ignored, that is, not put on the input queue
 725 and therefore not read by any process. If \fBIGNBRK\fR is not set and
 726 \fBBRKINT\fR is set, the break condition shall flush the input and output




 727 queues and if the terminal is the controlling terminal of a foreground process
 728 group, the break condition generates a single \fBSIGINT\fR signal to that
 729 foreground process group. If neither \fBIGNBRK\fR nor \fBBRKINT\fR is set, a
 730 break condition is read as a single '\e0' (\fBASCII NULL\fR) character, or if
 731 \fBPARMRK\fR is set, as '\e377', '\e0', c, where '\e377' is a single character
 732 with value 377 octal (0xff hex, 255 decimal), '\e0' is a single character with
 733 value 0, and c is the errored character received.
 734 .sp
 735 .LP
 736 If  \fBIGNPAR\fR is set, a byte with framing or parity errors (other than























 737 break)  is ignored.
 738 .sp
 739 .LP
 740 If \fBPARMRK\fR is set, and \fBIGNPAR\fR is not set, a byte with a framing or



 741 parity error (other than break) is given to the application as the
 742 three-character sequence: '\e377', '\e0', c, where '\e377' is a single
 743 character with value 377 octal (0xff hex, 255 decimal), '\e0' is a single
 744 character with value 0, and c is the errored character received. To avoid
 745 ambiguity in this case, if \fBISTRIP\fR is not set, a valid character
 746 of '\e377' is given to the  application as `\e377.' If neither \fBIGNPAR\fR nor
 747 \fBPARMRK\fR is set, a framing or parity error (other than break) is given to
 748 the application as a single '\e0' (\fBASCII NULL\fR) character.
 749 .sp
 750 .LP
 751 If \fBINPCK\fR is set, input parity checking is enabled. If \fBINPCK\fR is not
 752 set, input parity checking is disabled. This allows output parity generation
 753 without input parity errors.  Note that whether input parity checking is

























 754 enabled or disabled is independent of whether parity detection is enabled or
 755 disabled.  If parity detection is enabled but input parity checking is

 756 disabled, the hardware to which the terminal is connected will recognize the
 757 parity bit, but the terminal special file will not check whether this is set
 758 correctly or not.
 759 .sp
 760 .LP
 761 If \fBISTRIP\fR is set, valid input characters are first stripped to seven

 762 bits, otherwise all eight bits are processed.
 763 .sp
 764 .LP
 765 If \fBINLCR\fR is set, a received \fBNL\fR character is translated into a
 766 \fBCR\fR character.  If  \fBIGNCR\fR is set, a received \fBCR\fR character is
 767 ignored (not read).  Otherwise, if \fBICRNL\fR is set, a received \fBCR\fR
 768 character is translated into a \fBNL\fR character.
 769 .sp
 770 .LP
 771 If \fBIUCLC\fR is set, a received upper case, alphabetic character is















 772 translated into the corresponding lower case character.
 773 .sp
 774 .LP
 775 If \fBIXON\fR is set, start/stop output control is enabled. A received
 776 \fBSTOP\fR character suspends output and a received \fBSTART\fR character
 777 restarts output. The \fBSTOP\fR and \fBSTART\fR characters will not be read,
 778 but will merely perform  flow control functions. If \fBIXANY\fR is set, any













 779 input character restarts output that has been suspended.
 780 .sp
 781 .LP
 782 If \fBIXOFF\fR is set, the system transmits a \fBSTOP\fR character when the
 783 input queue is nearly full, and a \fBSTART\fR character when enough input has





 784 been read so that the input queue is nearly empty again.
 785 .sp
 786 .LP
 787 If \fBIMAXBEL\fR is set, the \fBASCII BEL\fR character is echoed if the input
 788 stream overflows. Further input is not stored, but any input already present in
 789 the input stream is not disturbed.  If  \fBIMAXBEL\fR is not set, no \fBBEL\fR







 790 character is echoed, and all input present in the input queue is discarded if
 791 the input stream overflows.
 792 .SS "Output Modes"
 793 .LP
 794 The  \fBc_oflag\fR field specifies the  system treatment of output:
 795 .sp
 796 .ne 2
 797 .na
 798 \fB\fBOPOST\fR\fR
 799 .ad
 800 .RS 10n
 801 Post-process output.
 802 .RE
 803 
 804 .sp
 805 .ne 2
 806 .na
 807 \fB\fBOLCUC\fR\fR
 808 .ad
 809 .RS 10n
 810 Map lower case to upper on output.
 811 .RE
 812 
 813 .sp
 814 .ne 2
 815 .na
 816 \fB\fBONLCR\fR\fR
 817 .ad
 818 .RS 10n
 819 Map NL to CR-NL on output.
 820 .RE
 821 
 822 .sp
 823 .ne 2
 824 .na
 825 \fB\fBOCRNL\fR\fR
 826 .ad
 827 .RS 10n
 828 Map CR to NL on output.
 829 .RE
 830 
 831 .sp
 832 .ne 2
 833 .na
 834 \fB\fBONOCR\fR\fR
 835 .ad
 836 .RS 10n
 837 No \fBCR\fR output at column 0.
 838 .RE
 839 
 840 .sp
 841 .ne 2
 842 .na
 843 \fB\fBONLRET\fR\fR
 844 .ad
 845 .RS 10n
 846 \fBNL\fR performs \fBCR\fR function.
 847 .RE
 848 
 849 .sp
 850 .ne 2
 851 .na
 852 \fB\fBOFILL\fR\fR
 853 .ad
 854 .RS 10n
 855 Use fill characters for delay.
 856 .RE
 857 
 858 .sp
 859 .ne 2
 860 .na
 861 \fB\fBOFDEL\fR\fR
 862 .ad
 863 .RS 10n
 864 Fill is \fBDEL\fR, else \fINULL\fR.
 865 .RE
 866 
 867 .sp
 868 .ne 2
 869 .na
 870 \fB\fBNLDLY\fR\fR
 871 .ad
 872 .RS 10n
 873 Select newline delays:
 874 .br
 875 .in +2
 876 \fBNL0\fR
 877 .in -2
 878 .br
 879 .in +2
 880 \fBNL1\fR
 881 .in -2
 882 .RE
 883 
 884 .sp
 885 .ne 2
 886 .na
 887 \fB\fBCRDLY\fR\fR
 888 .ad
 889 .RS 10n
 890 Select carriage-return delays:
 891 .br
 892 .in +2
 893 \fBCR0\fR
 894 .in -2
 895 .br
 896 .in +2
 897 \fBCR1\fR
 898 .in -2
 899 .br
 900 .in +2
 901 \fBCR2\fR
 902 .in -2
 903 .br
 904 .in +2
 905 \fBCR3\fR
 906 .in -2
 907 .RE
 908 
 909 .sp
 910 .ne 2
 911 .na
 912 \fB\fBTABDLY\fR\fR
 913 .ad
 914 .RS 10n
 915 Select horizontal tab delays or tab expansion:
 916 .sp
 917 .ne 2
 918 .na
 919 \fB\fBTAB0\fR\fR
 920 .ad
 921 .RS 9n
 922 
 923 .RE
 924 
 925 .sp
 926 .ne 2
 927 .na
 928 \fB\fBTAB1\fR\fR
 929 .ad
 930 .RS 9n
 931 
 932 .RE
 933 
 934 .sp
 935 .ne 2
 936 .na
 937 \fB\fBTAB2\fR\fR
 938 .ad
 939 .RS 9n
 940 
 941 .RE
 942 
 943 .sp
 944 .ne 2
 945 .na
 946 \fB\fBTAB3\fR\fR
 947 .ad
 948 .RS 9n
 949 Expand tabs to spaces
 950 .RE
 951 
 952 .sp
 953 .ne 2
 954 .na
 955 \fB\fBXTABS\fR\fR
 956 .ad
 957 .RS 9n
 958 Expand tabs to spaces
 959 .RE
 960 
 961 .RE
 962 
 963 .sp
 964 .ne 2
 965 .na
 966 \fB\fBBSDLY\fR\fR
 967 .ad
 968 .RS 10n
 969 Select backspace delays:
 970 .br
 971 .in +2
 972 \fBBS0\fR
 973 .in -2
 974 .br
 975 .in +2
 976 \fBBS1\fR
 977 .in -2
 978 .RE
 979 
 980 .sp
 981 .ne 2
 982 .na
 983 \fB\fBVTDLY\fR\fR
 984 .ad
 985 .RS 10n
 986 Select vertical tab delays:
 987 .br
 988 .in +2
 989 \fBVT0\fR
 990 .in -2
 991 .br
 992 .in +2
 993 \fBVT1\fR
 994 .in -2
 995 .RE
 996 
 997 .sp
 998 .ne 2
 999 .na
1000 \fB\fBFFDLY\fR\fR
1001 .ad
1002 .RS 10n
1003 Select form feed delays:
1004 .br
1005 .in +2
1006 \fBFF0\fR
1007 .in -2
1008 .br
1009 .in +2
1010 \fBFF1\fR
1011 .in -2
1012 .RE
1013 
1014 .sp
1015 .LP
1016 If \fBOPOST\fR is set, output characters are post-processed as indicated by the
1017 remaining flags; otherwise, characters are transmitted without change.
1018 .sp
1019 .LP
1020 If \fBOLCUC\fR is set, a lower case alphabetic character is transmitted as the
1021 corresponding upper case character. This function is often used in conjunction
1022 with \fBIUCLC.\fR
1023 .sp
1024 .LP
1025 If \fBONLCR\fR is set, the \fBNL\fR character is transmitted as the \fBCR-NL\fR
1026 character pair.  If  \fBOCRNL\fR is set, the \fBCR\fR character is transmitted
1027 as the \fBNL\fR character.  If \fBONOCR\fR is set, no \fBCR\fR character is
1028 transmitted when at column 0 (first position). If  \fBONRET\fR is set, the
1029 \fBNL\fR character is assumed to do the carriage-return function; the column
1030 pointer is set to 0 and the delays specified for \fBCR\fR are used.  Otherwise,
1031 the \fBNL\fR character is assumed to do just the line-feed function; the column
1032 pointer remains unchanged. The column pointer is also set to 0 if the \fBCR\fR



























1033 character is actually transmitted.
1034 .sp
1035 .LP
1036 The delay bits specify how long transmission stops to allow for mechanical or
1037 other movement when certain characters are sent to the terminal. In all cases,
1038 a value of 0 indicates no delay. If  \fBOFILL\fR is set, fill characters are
1039 transmitted for delay instead of a timed delay. This is useful for high baud
1040 rate terminals that need only a minimal delay.  If  \fBOFDEL\fR is set, the
1041 fill character is \fBDEL\fR ; otherwise it is  \fINULL\fR.
1042 .sp
1043 .LP







1044 If a form-feed or vertical-tab delay is specified, it lasts for about 2
1045 seconds.
1046 .sp
1047 .LP
1048 Newline delay lasts about 0.10 seconds. If \fBONLRET\fR is set, the
1049 carriage-return delays are used instead of the newline delays. If \fBOFILL\fR



1050 is set, two fill characters are transmitted.
1051 .sp
1052 .LP
1053 Carriage-return delay type 1 is dependent on the current column position, type
1054 2 is about 0.10 seconds, and type 3 is about 0.15 seconds. If  \fBOFILL\fR is
1055 set, delay type 1 transmits two fill characters, and type 2 transmits four fill
1056 characters.
1057 .sp
1058 .LP
1059 Horizontal-tab delay type 1 is dependent on the current column position. Type 2
1060 is about 0.10 seconds. Type 3 specifies that tabs are to be expanded into
1061 spaces. If \fBOFILL\fR is set, two fill characters are transmitted for any
1062 delay.
1063 .sp
1064 .LP
1065 Backspace delay lasts about 0.05 seconds. If  \fBOFILL\fR is set, one fill
1066 character is transmitted.
1067 .sp
1068 .LP



1069 The actual delays depend on line speed and system load.
1070 .SS "Control Modes"
1071 .LP
1072 The \fBc_cflag\fR field describes the hardware control of the terminal:
1073 .sp
1074 .ne 2
1075 .na
1076 \fB\fBCBAUD\fR\fR
1077 .ad
1078 .RS 13n
1079 Baud rate:
1080 .RE
1081 
1082 .sp
1083 .ne 2
1084 .na
1085 \fB\fBB0\fR\fR
1086 .ad
1087 .RS 13n
1088 Hang up
1089 .RE
1090 
1091 .sp
1092 .ne 2
1093 .na
1094 \fB\fBB50\fR\fR
1095 .ad
1096 .RS 13n
1097 50 baud
1098 .RE
1099 
1100 .sp
1101 .ne 2
1102 .na
1103 \fB\fBB75\fR\fR
1104 .ad
1105 .RS 13n
1106 75 baud
1107 .RE
1108 
1109 .sp
1110 .ne 2
1111 .na
1112 \fB\fBB110\fR\fR
1113 .ad
1114 .RS 13n
1115 110 baud
1116 .RE
1117 
1118 .sp
1119 .ne 2
1120 .na
1121 \fB\fBB134\fR\fR
1122 .ad
1123 .RS 13n
1124 134 baud
1125 .RE
1126 
1127 .sp
1128 .ne 2
1129 .na
1130 \fB\fBB150\fR\fR
1131 .ad
1132 .RS 13n
1133 150 baud
1134 .RE
1135 
1136 .sp
1137 .ne 2
1138 .na
1139 \fB\fBB200\fR\fR
1140 .ad
1141 .RS 13n
1142 200 baud
1143 .RE
1144 
1145 .sp
1146 .ne 2
1147 .na
1148 \fB\fBB300\fR\fR
1149 .ad
1150 .RS 13n
1151 300 baud
1152 .RE
1153 
1154 .sp
1155 .ne 2
1156 .na
1157 \fB\fBB600\fR\fR
1158 .ad
1159 .RS 13n
1160 600 baud
1161 .RE
1162 
1163 .sp
1164 .ne 2
1165 .na
1166 \fB\fBB1200\fR\fR
1167 .ad
1168 .RS 13n
1169 1200 baud
1170 .RE
1171 
1172 .sp
1173 .ne 2
1174 .na
1175 \fB\fBB1800\fR\fR
1176 .ad
1177 .RS 13n
1178 1800 baud
1179 .RE
1180 
1181 .sp
1182 .ne 2
1183 .na
1184 \fB\fBB2400\fR\fR
1185 .ad
1186 .RS 13n
1187 2400 baud
1188 .RE
1189 
1190 .sp
1191 .ne 2
1192 .na
1193 \fB\fBB4800\fR\fR
1194 .ad
1195 .RS 13n
1196 4800 baud
1197 .RE
1198 
1199 .sp
1200 .ne 2
1201 .na
1202 \fB\fBB9600\fR\fR
1203 .ad
1204 .RS 13n
1205 9600 baud
1206 .RE
1207 
1208 .sp
1209 .ne 2
1210 .na
1211 \fB\fBB19200\fR\fR
1212 .ad
1213 .RS 13n
1214 19200 baud
1215 .RE
1216 
1217 .sp
1218 .ne 2
1219 .na
1220 \fB\fBEXTA\fR\fR
1221 .ad
1222 .RS 13n
1223 External A
1224 .RE
1225 
1226 .sp
1227 .ne 2
1228 .na
1229 \fB\fBB38400\fR\fR
1230 .ad
1231 .RS 13n
1232 38400 baud
1233 .RE
1234 
1235 .sp
1236 .ne 2
1237 .na
1238 \fB\fBEXTB\fR\fR
1239 .ad
1240 .RS 13n
1241 External B
1242 .RE
1243 
1244 .sp
1245 .ne 2
1246 .na
1247 \fB\fBB57600\fR\fR
1248 .ad
1249 .RS 13n
1250 57600 baud
1251 .RE
1252 
1253 .sp
1254 .ne 2
1255 .na
1256 \fB\fBB76800\fR\fR
1257 .ad
1258 .RS 13n
1259 76800 baud
1260 .RE
1261 
1262 .sp
1263 .ne 2
1264 .na
1265 \fB\fBB115200\fR\fR
1266 .ad
1267 .RS 13n
1268 115200 baud
1269 .RE
1270 
1271 .sp
1272 .ne 2
1273 .na
1274 \fB\fBB153600\fR\fR
1275 .ad
1276 .RS 13n
1277 153600 baud
1278 .RE
1279 
1280 .sp
1281 .ne 2
1282 .na
1283 \fB\fBB230400\fR\fR
1284 .ad
1285 .RS 13n
1286 230400 baud
1287 .RE
1288 
1289 .sp
1290 .ne 2
1291 .na
1292 \fB\fBB307200\fR\fR
1293 .ad
1294 .RS 13n
1295 307200 baud
1296 .RE
1297 
1298 .sp
1299 .ne 2
1300 .na
1301 \fB\fBB460800\fR\fR
1302 .ad
1303 .RS 13n
1304 460800 baud
1305 .RE
1306 
1307 .sp
1308 .ne 2
1309 .na
1310 \fB\fBCSIZE\fR\fR
1311 .ad
1312 .RS 13n
1313 Character size:
1314 .RE
1315 
1316 .sp
1317 .ne 2
1318 .na
1319 \fB\fBCS5\fR\fR
1320 .ad
1321 .RS 13n
1322 5 bits
1323 .RE
1324 
1325 .sp
1326 .ne 2
1327 .na
1328 \fB\fBCS6\fR\fR
1329 .ad
1330 .RS 13n
1331 6 bits
1332 .RE
1333 
1334 .sp
1335 .ne 2
1336 .na
1337 \fB\fBCS7\fR\fR
1338 .ad
1339 .RS 13n
1340 7 bits
1341 .RE
1342 
1343 .sp
1344 .ne 2
1345 .na
1346 \fB\fBCS8\fR\fR
1347 .ad
1348 .RS 13n
1349 8 bits
1350 .RE
1351 
1352 .sp
1353 .ne 2
1354 .na
1355 \fB\fBCSTOPB\fR\fR
1356 .ad
1357 .RS 13n
1358 Send two stop bits, else one
1359 .RE
1360 
1361 .sp
1362 .ne 2
1363 .na
1364 \fB\fBCREAD\fR\fR
1365 .ad
1366 .RS 13n
1367 Enable receiver
1368 .RE
1369 
1370 .sp
1371 .ne 2
1372 .na
1373 \fB\fBPARENB\fR\fR
1374 .ad
1375 .RS 13n
1376 Parity enable
1377 .RE
1378 
1379 .sp
1380 .ne 2
1381 .na
1382 \fB\fBPARODD\fR\fR
1383 .ad
1384 .RS 13n
1385 Odd parity, else even
1386 .RE
1387 
1388 .sp
1389 .ne 2
1390 .na
1391 \fB\fBHUPCL\fR\fR
1392 .ad
1393 .RS 13n
1394 Hang up on last close
1395 .RE
1396 
1397 .sp
1398 .ne 2
1399 .na
1400 \fB\fBCLOCAL\fR\fR
1401 .ad
1402 .RS 13n
1403 Local line, else dial-up
1404 .RE
1405 
1406 .sp
1407 .ne 2
1408 .na
1409 \fB\fBCIBAUD\fR\fR
1410 .ad
1411 .RS 13n
1412 Input baud rate, if different from output rate
1413 .RE
1414 
1415 .sp
1416 .ne 2
1417 .na
1418 \fB\fBPAREXT\fR\fR
1419 .ad
1420 .RS 13n
1421 Extended parity for mark and space parity
1422 .RE
1423 
1424 .sp
1425 .ne 2
1426 .na
1427 \fB\fBCRTSXOFF\fR\fR
1428 .ad
1429 .RS 13n
1430 Enable inbound hardware flow control
1431 .RE
1432 
1433 .sp
1434 .ne 2
1435 .na
1436 \fB\fBCRTSCTS\fR\fR
1437 .ad
1438 .RS 13n
1439 Enable outbound hardware flow control
1440 .RE
1441 
1442 .sp
1443 .ne 2
1444 .na
1445 \fB\fBCBAUDEXT\fR\fR
1446 .ad
1447 .RS 13n
1448 Bit to indicate output speed > B38400
1449 .RE
1450 
1451 .sp
1452 .ne 2
1453 .na
1454 \fB\fBCIBAUDEXT\fR\fR
1455 .ad
1456 .RS 13n
1457 Bit to indicate input speed > B38400
1458 .RE
1459 
1460 .sp
1461 .LP
1462 The \fBCBAUD\fR bits together with the \fBCBAUDEXT\fR bit specify the output
1463 baud rate. To retrieve the output speed from the \fBtermios\fR structure
1464 pointed to by \fBtermios_p\fR see the following code segment.
1465 .sp
1466 .in +2
1467 .nf




1468 speed_t ospeed;
1469 if (termios_p->c_cflag & CBAUDEXT)
1470    ospeed = (termios_p->c_cflag & CBAUD) + CBAUD + 1;
1471 else
1472    ospeed = termios_p->c_cflag & CBAUD;
1473 .fi
1474 .in -2
1475 
1476 .sp
1477 .LP
1478 To store the output speed in the termios structure pointed to by
1479 \fBtermios_p\fR see the following code segment.
1480 .sp
1481 .in +2
1482 .nf
1483 speed_t ospeed;
1484 if (ospeed > CBAUD) {
1485    termios_p->c_cflag |= CBAUDEXT;
1486    ospeed -= (CBAUD + 1);
1487 } else
1488    termios_p->c_cflag &= ~CBAUDEXT;
1489  termios_p->c_cflag =

1490         (termios_p->c_cflag & ~CBAUD) | (ospeed & CBAUD);
1491 .fi
1492 .in -2
1493 
1494 .sp
1495 .LP
1496 The zero baud rate, B0, is used to hang up the connection. If B0 is specified,
1497 the data-terminal-ready signal is not asserted. Normally, this disconnects the
1498 line.
1499 .sp
1500 .LP
1501 If the \fBCIBAUDEXT\fR or \fBCIBAUD\fR bits are not zero, they specify the
1502 input baud rate, with the \fBCBAUDEXT\fR and \fBCBAUD\fR bits specifying the
1503 output baud rate; otherwise, the output and input baud rates are both specified
1504 by the \fBCBAUDEXT\fR and  \fBCBAUD\fR bits.  The values for the \fBCIBAUD\fR
1505 bits are the same as the values for the \fBCBAUD\fR bits, shifted left
1506 \fBIBSHIFT\fR bits. For any particular hardware, impossible speed changes are
1507 ignored. To retrieve the input speed in the  \fBtermios\fR structure pointed to
1508 by  \fBtermios_p\fR see the following code segment.
1509 .sp
1510 .in +2
1511 .nf



















1512 speed_t ispeed;
1513 if (termios_p->c_cflag & CIBAUDEXT)
1514    ispeed = ((termios_p->c_cflag & CIBAUD) >> IBSHIFT)
1515    + (CIBAUD >> IBSHIFT) + 1;
1516 else
1517    ispeed = (termios_p->c_cflag & CIBAUD) >> IBSHIFT;
1518 .fi
1519 .in -2
1520 
1521 .sp
1522 .LP
1523 To store the input speed in the  \fBtermios\fR structure pointed to by
1524 \fBtermios_p\fR see the following code segment.
1525 .sp
1526 .in +2
1527 .nf
1528 speed_t ispeed;
1529 if (ispeed == 0) {
1530    ispeed = termios_p->c_cflag & CBAUD;
1531 if (termios_p->c_cflag & CBAUDEXT)
1532    ispeed += (CBAUD + 1);
1533 }
1534  if ((ispeed << IBSHIFT) > CIBAUD) {
1535     termios_p->c_cflag |= CIBAUDEXT;
1536     ispeed -= ((CIBAUD >> IBSHIFT) + 1);
1537 } else
1538     termios_p->c_cflag &= ~CIBAUDEXT;
1539     termios_p->c_cflag =
1540     (termios_p->c_cflag & ~CIBAUD) |
1541            ((ispeed << IBSHIFT) & CIBAUD);
1542 .fi
1543 .in -2
1544 
1545 .sp
1546 .LP
1547 The \fBCSIZE\fR bits specify the character size in bits for both transmission
1548 and reception. This size does not include the parity bit, if any. If
1549 \fBCSTOPB\fR is set, two stop bits are used; otherwise, one stop bit is used.

1550 For example, at 110 baud, two stops bits are required.
1551 .sp
1552 .LP
1553 If \fBPARENB\fR is set, parity generation and detection is enabled, and a
1554 parity bit is added to each character. If parity is enabled, the \fBPARODD\fR



1555 flag specifies odd parity if set; otherwise, even parity is used.
1556 .sp
1557 .LP
1558 If \fBCREAD\fR is set, the receiver is enabled. Otherwise, no characters are
1559 received.
1560 .sp
1561 .LP
1562 If \fBHUPCL\fR is set, the line is disconnected when the last process with the
1563 line open closes it or terminates. That is, the data-terminal-ready signal is
1564 not asserted.
1565 .sp
1566 .LP
1567 If \fBCLOCAL\fR is set, the line is assumed to be a local, direct connection



1568 with no modem control; otherwise, modem control is assumed.
1569 .sp
1570 .LP
1571 If \fBCRTSXOFF\fR is set, inbound hardware flow control is enabled.
1572 .sp
1573 .LP
1574 If  \fBCRTSCTS\fR is set, outbound hardware flow control is enabled.
1575 .sp
1576 .LP
1577 The four possible combinations for the state of \fBCRTSCTS\fR and
1578 \fBCRTSXOFF\fR bits and their interactions are described below.
1579 .sp
1580 .ne 2
1581 .na
1582 \fBCase A:\fR
1583 .ad
1584 .RS 11n
1585 \fBCRTSCTS\fR off, \fBCRTSXOFF\fR off. In this case the hardware flow control
1586 is disabled.
1587 .RE
1588 
1589 .sp
1590 .ne 2
1591 .na
1592 \fBCase B:\fR
1593 .ad
1594 .RS 11n
1595 \fBCRTSCTS\fR on, \fBCRTSXOFF\fR off. In this case only outbound hardware flow
1596 control is enabled. The state of CTS signal is used to do outbound flow
1597 control. It is expected that output will be suspended if CTS is low and resumed
1598 when CTS is high.
1599 .RE
1600 
1601 .sp
1602 .ne 2
1603 .na
1604 \fBCase C:\fR
1605 .ad
1606 .RS 11n
1607 \fBCRTSCTS\fR off, \fBCRTSXOFF\fR on. In this case only inbound hardware flow
1608 control is enabled. The state of RTS signal is used to do inbound flow control.
1609 It is expected that input will be suspended if RTS is low and resumed when RTS
1610 is high.
1611 .RE
1612 
1613 .sp
1614 .ne 2
1615 .na
1616 \fBCase D:\fR
1617 .ad
1618 .RS 11n
1619 \fBCRTSCTS\fR on, \fBCRTSXOFF\fR on. In this case both inbound and outbound
1620 hardware flow control are enabled. Uses the state of CTS signal to do outbound
1621 flow control and RTS signal to do inbound flow control.
1622 .RE
1623 
1624 .SS "Local Modes"
1625 .LP
1626 The \fBc_lflag\fR field of the argument structure is used by the line
1627 discipline to control terminal functions. The basic line discipline provides
1628 the following:
1629 .sp
1630 .ne 2
1631 .na
1632 \fB\fBISIG\fR\fR
1633 .ad
1634 .RS 11n
1635  Enable signals.
1636 .RE
1637 
1638 .sp
1639 .ne 2
1640 .na
1641 \fB\fBICANON\fR\fR
1642 .ad
1643 .RS 11n
1644 Canonical input (erase and kill processing).
1645 .RE
1646 
1647 .sp
1648 .ne 2
1649 .na
1650 \fB\fBXCASE\fR\fR
1651 .ad
1652 .RS 11n
1653 Canonical upper/lower presentation.
1654 .RE
1655 
1656 .sp
1657 .ne 2
1658 .na
1659 \fB\fBECHO\fR\fR
1660 .ad
1661 .RS 11n
1662 Enable echo.
1663 .RE
1664 
1665 .sp
1666 .ne 2
1667 .na
1668 \fB\fBECHOE\fR\fR
1669 .ad
1670 .RS 11n
1671 Echo erase character as \fBBS-SP-BS\fR &.
1672 .RE
1673 
1674 .sp
1675 .ne 2
1676 .na
1677 \fB\fBECHOK\fR\fR
1678 .ad
1679 .RS 11n
1680 Echo  \fBNL\fR after kill character.
1681 .RE
1682 
1683 .sp
1684 .ne 2
1685 .na
1686 \fB\fBECHONL\fR\fR
1687 .ad
1688 .RS 11n
1689 Echo  \fBNL\fR .
1690 .RE
1691 
1692 .sp
1693 .ne 2
1694 .na
1695 \fB\fBNOFLSH\fR\fR
1696 .ad
1697 .RS 11n
1698 Disable flush after interrupt or quit.
1699 .RE
1700 
1701 .sp
1702 .ne 2
1703 .na
1704 \fB\fBTOSTOP\fR\fR
1705 .ad
1706 .RS 11n
1707 Send  \fBSIGTTOU\fR for background output.
1708 .RE
1709 
1710 .sp
1711 .ne 2
1712 .na
1713 \fB\fBECHOCTL\fR\fR
1714 .ad
1715 .RS 11n
1716 Echo control characters as  \fIchar,\fR delete as ^?.
1717 .RE
1718 
1719 .sp
1720 .ne 2
1721 .na
1722 \fB\fBECHOPRT\fR\fR
1723 .ad
1724 .RS 11n
1725 Echo erase character as character erased.
1726 .RE
1727 
1728 .sp
1729 .ne 2
1730 .na
1731 \fB\fBECHOKE\fR\fR
1732 .ad
1733 .RS 11n
1734 \fBBS-SP-BS\fR erase entire line on line kill.
1735 .RE
1736 
1737 .sp
1738 .ne 2
1739 .na
1740 \fB\fBFLUSHO\fR\fR
1741 .ad
1742 .RS 11n
1743 Output is being flushed.
1744 .RE
1745 
1746 .sp
1747 .ne 2
1748 .na
1749 \fB\fBPENDIN\fR\fR
1750 .ad
1751 .RS 11n
1752 Retype pending input at next read or  input character.
1753 .RE
1754 
1755 .sp
1756 .ne 2
1757 .na
1758 \fB\fBIEXTEN\fR\fR
1759 .ad
1760 .RS 11n
1761 Enable extended (implementation-defined) functions.
1762 .RE
1763 
1764 .sp
1765 .LP
1766 If \fBISIG\fR is set, each input character is checked against the special
1767 control characters INTR, QUIT, SWTCH,  SUSP, STATUS, and \fBDSUSP\fR. If an
1768 input character matches one of these control characters, the function
1769 associated with that character is performed. (Note: If SWTCH is set and the
1770 character matches, the character is simply discarded. No other action is
1771 taken.) If \fBISIG\fR is not set, no checking is done.  Thus, these special
1772 input functions are possible only if \fBISIG\fR is set.
1773 .sp
1774 .LP
1775 If \fBICANON\fR is set, canonical processing is enabled. This enables the erase



















1776 and kill edit functions, and the assembly of input characters into lines
1777 delimited by \fBNL-c\fR, \fBEOF\fR, \fBEOL\fR, and \fBEOL\fR . If  \fBICANON\fR
1778 is not set, read requests are satisfied directly from the input queue. A read
1779 is not satisfied until at least \fBMIN\fR characters have been  received or the
1780 timeout value \fBTIME\fR has expired between characters. This allows fast
1781 bursts of input to be read efficiently while still allowing single character
1782 input. The time value represents tenths of seconds.
1783 .sp
1784 .LP
1785 If  \fBXCASE\fR is set and \fBICANON\fR is set, an upper case letter is
1786 accepted on input if preceded by a backslash \fB(\e)\fR character, and is
1787 output preceded by a  backslash \fB(\e)\fR character. In this mode, the


















1788 following escape sequences are generated on output and accepted on input:
1789 .sp
1790 
1791 .sp
1792 .TS
1793 box;
1794 c | c
1795 l | l .
1796 FOR:    USE:
1797 _
1798 `       \e'
1799 _
1800 |       \e!
1801 _
1802 \(ap    \e^
1803 _
1804 {       \e(
1805 _
1806 }       \e)
1807 _
1808 \e      \e\e
1809 .TE
1810 
1811 .sp
1812 .LP
1813 For example, input A as \ea, \en as \e\en, and \eN as \e\e\en.
1814 .sp
1815 .LP
1816 If \fBECHO\fR is set, characters are echoed as received.
1817 .sp
1818 .LP
1819 When \fBICANON\fR is set, the following echo functions are possible.
1820 .RS +4
1821 .TP
1822 .ie t \(bu
1823 .el o
1824 If \fBECHO\fR and \fBECHOE\fR are set, and  \fBECHOPRT\fR is not set,  the
1825 \fBERASE\fR, \fBERASE2\fR, and \fBWERASE\fR characters are echoed as one or
1826 more ASCII BS SP BS, which clears the last character(s) from a \fBCRT\fR screen.
1827 .RE
1828 .RS +4
1829 .TP
1830 .ie t \(bu
1831 .el o
1832 If \fBECHO\fR, \fBECHOPRT\fR, and \fBIEXTEN\fR are set, the first \fBERASE\fR,
1833 \fBERASE2\fR, and \fBWERASE\fR character in a sequence echoes as a backslash
1834 (\fB\e\fR), followed by the characters being erased.  Subsequent \fBERASE\fR and
1835 \fBWERASE\fR characters echo the characters being erased, in reverse order. The
1836 next non-erase character causes a `/' (slash) to be typed before it is echoed.
1837 \fBECHOPRT\fR should be used for hard copy terminals.
1838 .RE
1839 .RS +4
1840 .TP
1841 .ie t \(bu
1842 .el o
1843 If  \fBECHOKE\fR and \fBIEXTEN\fR are set, the kill character is echoed by


























1844 erasing each  character on the line from the screen (using the mechanism
1845 selected by \fBECHOE\fR and \fBECHOPR\fRa).
1846 .RE
1847 .RS +4
1848 .TP
1849 .ie t \(bu
1850 .el o
1851 If  \fBECHOK\fR is set, and \fBECHOKE\fR is not set, the \fBNL\fR character is
1852 echoed after the kill character to emphasize that the line is deleted. Note
1853 that a `\' (escape) character or an \fBLNEXT\fR character preceding the erase










1854 or kill character removes any special function.
1855 .RE
1856 .RS +4
1857 .TP
1858 .ie t \(bu
1859 .el o
1860 If  \fBECHONL\fR is set, the \fBNL\fR character is echoed even if  \fBECHO\fR
1861 is not set.  This is useful for terminals set to local echo (so called


1862 half-duplex).
1863 .RE
1864 .sp
1865 .LP
1866 If \fBECHOCTL\fR and \fBIEXTEN\fR are set, all control characters (characters
1867 with codes between 0 and 37 octal) other than  \fBASCII TAB\fR, \fBASCII NL\fR,
1868 the \fBSTART\fR character, and the \fBSTOP\fR character,  \fBASCII CR\fR, and
1869 \fBASCII BS\fR are echoed as ^ \fBX,\fR where \fBX\fR is the character given by
1870 adding 100 octal to the code of the  control character (so that the character
1871 with octal code 1 is echoed as ^ \fBA),\fR and the \fBASCII DEL\fR character,
1872 with code 177 octal, is echoed as ^ \fB?\fR.
1873 .sp
1874 .LP
1875 If  \fBNOFLSH\fR is set, the normal flush of the input and output queues
1876 associated with the \fBINTR\fR, \fBQUIT\fR, \fBSTATUS\fR, and \fBSUSP\fR
1877 characters is not done.  This bit should be set when restarting system calls
1878 that read from or write to a terminal (see  \fBsigaction\fR(2)\|).
1879 .sp
1880 .LP
1881 If  \fBTOSTOP\fR and \fBIEXTEN\fR are set, the signal  \fBSIGTTOU\fR is sent to










































1882 a process that tries to write to its controlling terminal if it is not in the
1883 foreground process group for that terminal. This signal normally stops the
1884 process. Otherwise, the output generated by that process is output to the
1885 current output stream. Processes that are blocking or ignoring  \fBSIGTTOU\fR



1886 signals are excepted and allowed to produce output, if any.
1887 .sp
1888 .LP
1889 If \fBFLUSHO\fR and \fBIEXTEN\fR are set, data written to the terminal is
1890 discarded. This bit is set when the \fBFLUSH\fR character is typed. A program
1891 can cancel the effect of typing the \fBFLUSH\fR character by clearing
1892 \fBFLUSHO\fR.
1893 .sp
1894 .LP
1895 If \fBPENDIN\fR and  \fBIEXTEN\fR are set, any input that has not yet been read
1896 is reprinted when the next character arrives as input. \fBPENDIN\fR is then













1897 automatically cleared.
1898 .sp
1899 .LP
1900 If \fBIEXTEN\fR is set, the following implementation-defined functions are
1901 enabled:  special characters ( \fBWERASE\fR, \fBREPRINT\fR, \fBDISCARD\fR, and
1902 \fBLNEXT\fR) and local flags ( \fBTOSTOP\fR, \fBECHOCTL\fR, \fBECHOPRT\fR,
1903 \fBECHOKE\fR, \fBFLUSHO\fR, and \fBPENDIN\fR).
1904 .SS "Minimum and Timeout"
1905 .LP
1906 The \fBMIN\fR and \fBTIME\fR values were described previously, in the
1907 subsection, \fBNon-canonical Mode Input Processing\fR. The initial value of
1908 \fBMIN\fR is 1, and the initial value of \fBTIME\fR is 0.
1909 .SS "Terminal Size"
1910 .LP



















1911 The number of lines and columns on the terminal's display is specified in the
1912 \fBwinsize\fR structure defined by  \fBsys/termios.h\fR and includes the
1913 following members:
1914 .sp
1915 .in +2
1916 .nf
1917 unsigned        short ws_row;  /* rows, in characters */
1918 unsigned short  ws_col;    /* columns, in characters */
1919 unsigned short  ws_xpixel; /* horizontal size, in pixels */
1920 unsigned short  ws_ypixel; /* vertical size, in pixels */
1921 .fi
1922 .in -2
1923 
1924 .SS "Termio Structure"
1925 .LP
1926 The SunOS/SVR4 \fBtermio\fR structure is used by some \fBioctl\fRs; it is
1927 defined by \fBsys/termio.h\fR and includes the following members:
1928 .sp
1929 .in +2
1930 .nf
1931 unsigned         short  c_iflag;  /* input modes */
1932 unsigned         short  c_oflag;  /* output modes */
1933 unsigned         short  c_cflag;  /* control modes */
1934 unsigned         short c_lflag; /* local modes */
1935 char c_line;                      /* line discipline */
1936 unsigned         char  c_cc[NCC];  /* control chars */
1937 .fi
1938 .in -2
1939 
1940 .sp
1941 .LP
1942 The special control characters are defined by the array \fBc_cc\fR. The
1943 symbolic name \fBNCC\fR is the size of the Control-character array and is also
1944 defined by \fBtermio.h\fR. The relative positions, subscript names, and typical


1945 default values  for each function are as follows:
1946 .sp
1947 
1948 .sp
1949 .TS
1950 box;
1951 c | c | c
1952 l | l | l .
1953 Relative Positions      Subscript Names Typical Default Values
1954 _
1955 0       VINTR   EXT
1956 _
1957 1       VQUIT   FS
1958 _
1959 2       VERASE  DEL
1960 _
1961 3       VKILL   NAK
1962 _
1963 4       VEOF    EOT
1964 _
1965 5       VEOL    NUL
1966 _
1967 6       VEOL2   NUL
1968 _
1969 7       Reserved        
1970 .TE
1971 
1972 .sp
1973 .LP
1974 The \fBMIN\fR values is stored in the \fBVMIN\fR element of the \fBc_cc\fR
1975 array; the \fBTIME\fR value is stored in the  \fBVTIME\fR element of the
1976 \fBc_cc\fR array. The  \fBVMIN\fR element is the same element as the
1977 \fBVEOF\fR element; the \fBVTIME\fR element is the same element as the
1978 \fBVEOL\fR element.
1979 .sp
1980 .LP
1981 The calls that use the \fBtermio\fR structure only affect the flags and control
1982 characters that can be stored in the \fBtermio\fR structure; all other flags
1983 and control characters are unaffected.
1984 .SS "Modem Lines"
1985 .LP


1986 On special files representing serial ports, modem control lines can be read.
1987 Control lines  (if the underlying hardware supports it) may also be changed.
1988 Status lines are read-only. The following modem control and status lines may be
1989 supported by a device; they are defined by \fBsys/termios.h\fR:
1990 .sp
1991 .ne 2
1992 .na
1993 \fB\fBTIOCM_LE\fR\fR
1994 .ad
1995 .RS 13n
1996  line enable
1997 .RE
1998 
1999 .sp
2000 .ne 2
2001 .na
2002 \fB\fBTIOCM_DTR\fR\fR
2003 .ad
2004 .RS 13n
2005 data terminal ready
2006 .RE
2007 
2008 .sp
2009 .ne 2
2010 .na
2011 \fB\fBTIOCM_RTS\fR\fR
2012 .ad
2013 .RS 13n
2014 request to send
2015 .RE
2016 
2017 .sp
2018 .ne 2
2019 .na
2020 \fB\fBTIOCM_ST\fR\fR
2021 .ad
2022 .RS 13n
2023 secondary transmit
2024 .RE
2025 
2026 .sp
2027 .ne 2
2028 .na
2029 \fB\fBTIOCM_SR\fR\fR
2030 .ad
2031 .RS 13n
2032 secondary receive
2033 .RE
2034 
2035 .sp
2036 .ne 2
2037 .na
2038 \fB\fBTIOCM_CTS\fR\fR
2039 .ad
2040 .RS 13n
2041 clear to send
2042 .RE
2043 
2044 .sp
2045 .ne 2
2046 .na
2047 \fB\fBTIOCM_CAR\fR\fR
2048 .ad
2049 .RS 13n
2050 carrier detect
2051 .RE
2052 
2053 .sp
2054 .ne 2
2055 .na
2056 \fB\fBTIOCM_RNG\fR\fR
2057 .ad
2058 .RS 13n
2059 ring
2060 .RE
2061 
2062 .sp
2063 .ne 2
2064 .na
2065 \fB\fBTIOCM_DSR\fR\fR
2066 .ad
2067 .RS 13n
2068 data set ready
2069 .RE
2070 
2071 .sp
2072 .LP
2073 \fBTIOCM_CD\fR is a synonym for \fBTIOCM_CAR\fR, and \fBTIOCM_RI\fR is a
2074 synonym for \fBTIOCM_RNG\fR. Not all of these are necessarily supported by any




2075 particular device; check the manual page for the device in question.
2076 .sp
2077 .LP
2078 The software carrier mode can be enabled or disabled using the
2079 \fBTIOCSSOFTCAR\fR \fBioctl\fR. If the software carrier flag for a line is off,
2080 the line pays attention to the hardware carrier detect (DCD) signal. The
2081 \fBtty\fR device associated with the line cannot be opened until \fBDCD\fR is
2082 asserted. If the software carrier flag is on, the line behaves as if \fBDCD\fR







2083 is always asserted.
2084 .sp
2085 .LP
2086 The software carrier flag is usually turned on for locally connected terminals
2087 or other devices, and is off for lines with modems.
2088 .sp
2089 .LP
2090 To be able to issue the \fBTIOCGSOFTCAR\fR and \fBTIOCSSOFTCAR\fR \fBioctl\fR
2091 calls, the \fBtty\fR line should be opened with \fBO_NDELAY\fR so that the
2092 \fBopen\fR(2) will not wait for the carrier.
2093 .SS "Default Values"
2094 .LP
2095 The initial  \fBtermios\fR values upon driver open is configurable. This is
2096 accomplished by setting the "ttymodes" property in the file
2097 \fB/kernel/drv/options.conf\fR. Since this property is assigned during system










2098 initialization,  any change to the "ttymodes" property will not take effect
2099 until the next reboot.  The string value assigned to this property should be in
2100 the same format as the output of the \fBstty\fR(1) command with the -g option.
2101 .sp
2102 .LP
2103 If this property is undefined, the following  \fBtermios\fR modes are in
2104 effect.  The initial input control value is \fBBRKINT\fR, \fBICRNL\fR,
2105 \fBIXON\fR, \fBIMAXBEL\fR. The initial output control value is \fBOPOST\fR,
2106 \fBONLCR\fR, \fBTAB3\fR. The initial hardware control value is \fBB9600\fR,
2107 \fBCS8\fR, \fBCREAD\fR. The initial line-discipline control value is
2108 \fBISIG\fR, \fBICANON\fR, \fBIEXTEN\fR, \fBECHO\fR, \fBECHOK\fR, \fBECHOE\fR,
2109 \fBECHOKE\fR, \fBECHOCTL\fR.
2110 .SH IOCTLS
2111 .LP
2112 The \fBioctl\fRs supported by devices and \fBSTREAMS\fR modules providing the
2113 \fBtermios\fR(3C) interface are listed below. Some calls may not be supported
2114 by all devices or modules.  The functionality provided by these calls is also

























2115 available through the preferred function call interface specified on
2116 \fBtermios\fR.
2117 .sp
2118 .ne 2
2119 .na
2120 \fB\fBTCGETS\fR\fR
2121 .ad
2122 .RS 16n
2123 The argument is a pointer to a \fBtermios\fR structure. The current terminal
2124 parameters are fetched and stored into that structure.
2125 .RE
2126 
2127 .sp
2128 .ne 2
2129 .na
2130 \fB\fBTCSETS\fR\fR
2131 .ad
2132 .RS 16n
2133 The argument is a pointer to a \fBtermios\fR structure. The current terminal
2134 parameters are set from the values stored in that structure. The change is
2135 immediate.
2136 .RE
2137 
2138 .sp
2139 .ne 2
2140 .na
2141 \fB\fBTCSETSW\fR\fR
2142 .ad
2143 .RS 16n
2144 The argument is a pointer to a \fBtermios\fR structure. The current terminal
2145 parameters are set from the values stored in that structure. The change occurs
2146 after all characters queued for output have been transmitted. This form should
2147 be used when changing parameters that affect output.
2148 .RE
2149 
2150 .sp
2151 .ne 2
2152 .na
2153 \fB\fBTCSETSF\fR\fR
2154 .ad
2155 .RS 16n
2156 The argument is a pointer to a \fBtermios\fR structure. The current terminal
2157 parameters are set from the values stored in that structure. The change occurs
2158 after all characters queued for output have been transmitted; all characters
2159 queued for input are discarded and then the change occurs.
2160 .RE
2161 
2162 .sp
2163 .ne 2
2164 .na
2165 \fB\fBTCGETA\fR\fR
2166 .ad
2167 .RS 16n
2168 The argument is a pointer to a \fBtermio\fR structure. The current terminal
2169 parameters are fetched, and those parameters that can be stored in a
2170 \fBtermio\fR structure are stored into that structure.
2171 .RE
2172 
2173 .sp
2174 .ne 2
2175 .na
2176 \fB\fBTCSETA\fR\fR
2177 .ad
2178 .RS 16n
2179 The argument is a pointer to a  \fBtermio\fR structure. Those terminal
2180 parameters that can be stored in a \fBtermio\fR structure are set from the
2181 values stored in that structure. The change is immediate.
2182 .RE
2183 
2184 .sp
2185 .ne 2
2186 .na
2187 \fB\fBTCSETAW\fR\fR
2188 .ad
2189 .RS 16n
2190 The argument is a pointer to a \fBtermio\fR structure. Those terminal
2191 parameters that can be stored in a \fBtermio\fR structure are set from the
2192 values stored in that structure. The change occurs after all characters queued
2193 for output have been transmitted. This form should be used when changing
2194 parameters that affect output.
2195 .RE
2196 
2197 .sp
2198 .ne 2
2199 .na
2200 \fB\fBTCSETAF\fR\fR
2201 .ad
2202 .RS 16n
2203 The argument is a pointer to a \fBtermio\fR structure.  Those terminal
2204 parameters that can be stored in a \fBtermio\fR structure are set from the
2205 values stored in that structure. The change occurs after all characters queued
2206 for output have been transmitted; all characters queued for input are discarded
2207 and then the change occurs.
2208 .RE
2209 
2210 .sp
2211 .ne 2
2212 .na
2213 \fB\fBTCSBRK\fR\fR
2214 .ad
2215 .RS 16n
2216 The argument is an \fBint\fR value. Wait for the output to drain. If the
2217 argument is \fB0\fR, then send a break (zero valued bits for 0.25 seconds).
2218 .RE
2219 
2220 .sp
2221 .ne 2
2222 .na
2223 \fB\fBTCXONC\fR\fR
2224 .ad
2225 .RS 16n
2226 Start/stop control. The argument is an \fBint\fR value. If the argument is
2227 \fB0\fR, suspend output; if \fB1\fR, restart suspended output; if \fB2\fR,
2228 suspend input; if \fB3\fR, restart suspended input.
2229 .RE
2230 
2231 .sp
2232 .ne 2
2233 .na
2234 \fB\fBTCFLSH\fR\fR
2235 .ad
2236 .RS 16n
2237 The argument is an \fBint\fR value. If the argument is \fB0\fR, flush the input
2238 queue; if \fB1\fR, flush the output queue; if \fB2\fR, flush both the input and
2239 output queues.
2240 .RE
2241 
2242 .sp
2243 .ne 2
2244 .na
2245 \fB\fBTIOCGPGRP\fR\fR
2246 .ad
2247 .RS 16n
2248 The argument is a pointer to a \fBpid_t\fR. Set the value of that  \fBpid_t\fR
2249 to the process group \fBID\fR of the foreground process group associated with
2250 the terminal. See  \fBtermios\fR(3C) for a description of  \fBTCGETPGRP\fR.
2251 .RE
2252 
2253 .sp
2254 .ne 2
2255 .na
2256 \fB\fBTIOCSPGRP\fR\fR
2257 .ad
2258 .RS 16n
2259 The argument is a pointer to a \fBpid_t\fR. Associate the process group whose
2260 process group \fBID\fR is specified by the value of that  \fBpid_t\fR with the
2261 terminal. The new process group value must be in the range of valid process
2262 group \fBID\fR values.  Otherwise, the error  \fBEPERM\fR is returned.
2263 .RE
2264 
2265 .sp
2266 .ne 2
2267 .na
2268 \fB\fBTIOCGSID\fR\fR
2269 .ad
2270 .RS 16n
2271 The argument is a pointer to a \fBpid_t\fR. The session ID of the terminal is
2272 fetched  and stored in the  \fBpid_t\fR.
2273 .RE
2274 
2275 .sp
2276 .ne 2
2277 .na
2278 \fB\fBTIOCGWINSZ\fR\fR
2279 .ad
2280 .RS 16n
2281 The argument is a pointer to a \fBwinsize\fR structure. The terminal driver's
2282 notion of the terminal size is stored into that structure.
2283 .RE
2284 
2285 .sp
2286 .ne 2
2287 .na
2288 \fB\fBTIOCSWINSZ\fR\fR
2289 .ad
2290 .RS 16n
2291 The argument is a pointer to a \fBwinsize\fR structure. The terminal driver's
2292 notion of the terminal size is set from the values specified in that structure.
2293 If the new sizes are different from the old sizes, a \fBSIGWINCH\fR signal is
2294 set to the process group of the terminal.
2295 .RE
2296 
2297 .sp
2298 .ne 2
2299 .na
2300 \fB\fBTIOCMBIS\fR\fR
2301 .ad
2302 .RS 16n
2303 The argument is a pointer to an \fBint\fR whose value is a mask containing
2304 modem control lines to be turned on. The control lines whose bits are set in
2305 the argument are turned on; no other control lines are affected.
2306 .RE
2307 
2308 .sp
2309 .ne 2
2310 .na
2311 \fB\fBTIOCMBIC\fR\fR
2312 .ad
2313 .RS 16n
2314 The argument is a pointer to an \fBint\fR whose value is a mask containing
2315 modem control lines to be turned off. The control lines whose bits are set in
2316 the argument are turned off; no other control lines are affected.
2317 .RE
2318 
2319 .sp
2320 .ne 2
2321 .na
2322 \fB\fBTIOCMGET\fR\fR
2323 .ad
2324 .RS 16n
2325 The argument is a pointer to an  \fBint\fR. The current state of the modem
2326 status lines is fetched and stored in the  \fBint\fR pointed to by the
2327 argument.
2328 .RE
2329 
2330 .sp
2331 .ne 2
2332 .na
2333 \fB\fBTIOCMSET\fR\fR
2334 .ad
2335 .RS 16n
2336 The argument is a pointer to an  \fBint\fR containing a new set of modem
2337 control lines. The modem control lines are turned on or off, depending on
2338 whether the bit for that mode is set or clear.
2339 .RE
2340 
2341 .sp
2342 .ne 2
2343 .na
2344 \fB\fBTIOCSPPS\fR\fR
2345 .ad
2346 .RS 16n
2347 The argument is a pointer to an \fBint\fR that determines whether
2348 pulse-per-second event handling is to be enabled (non-zero) or disabled (zero).
2349 If a one-pulse-per-second reference clock is attached to the serial line's data
2350 carrier detect input, the local system clock will be calibrated to it. A clock
2351 with a high error, that is, a deviation of more than 25 microseconds per tick,
2352 is ignored.
2353 .RE
2354 
2355 .sp
2356 .ne 2
2357 .na
2358 \fB\fBTIOCGPPS\fR\fR
2359 .ad
2360 .RS 16n
2361 The argument is a pointer to an \fBint\fR, in which the state of the even
2362 handling is returned. The \fBint\fR is set to a non-zero value if
2363 pulse-per-second (PPS) handling has been enabled. Otherwise, it is set to zero.
2364 .RE
2365 
2366 .sp
2367 .ne 2
2368 .na
2369 \fB\fBTIOCGSOFTCAR\fR\fR
2370 .ad
2371 .RS 16n
2372 The argument is a pointer to an \fBint\fR whose value is \fB1\fR or \fB0\fR,
2373 depending on whether the software carrier detect is turned on or off.
2374 .RE
2375 
2376 .sp
2377 .ne 2
2378 .na
2379 \fB\fBTIOCSSOFTCAR\fR\fR
2380 .ad
2381 .RS 16n
2382 The argument is a pointer to an \fBint\fR whose value is \fB1\fR or \fB0\fR.
2383 The value of the integer should be \fB0\fR to turn off software carrier, or
2384 \fB1\fR to turn it on.
2385 .RE
2386 
2387 .sp
2388 .ne 2
2389 .na
2390 \fB\fBTIOCGPPSEV\fR\fR
2391 .ad
2392 .RS 16n
2393 The argument is a pointer to a \fBstruct\fR \fBppsclockev\fR. This structure
2394 contains the following members:
2395 .sp
2396 .in +2
2397 .nf
2398 struct timeval tv;
2399 uint32_t serial;
2400 .fi
2401 .in -2
2402 
2403 "tv" is the system clock timestamp when the event (pulse on the \fBDCD\fR pin)
2404 occurred. "serial" is the ordinal of the event, which each consecutive event
2405 being assigned the next ordinal. The first event registered gets a "serial"
2406 value of \fB1\fR. The \fBTIOCGPPSEV\fR returns the last event registered;
2407 multiple calls will persistently return the same event until a new one is
2408 registered. In addition to time stamping and saving the event, if it is of









2409 one-second period and of consistently high accuracy, the local system clock
2410 will automatically calibrate to it.
2411 .RE
2412 
2413 .SH FILES
2414 .LP
2415 Files in or under /\fBdev\fR
2416 .SH SEE ALSO
2417 .LP
2418 \fBstty\fR(1), \fBfork\fR(2), \fBgetpgid\fR(2), \fBgetsid\fR(2),
2419 \fBioctl\fR(2), \fBsetsid\fR(2), \fBsigaction\fR(2), \fBsignal\fR(3C),
2420 \fBtcsetpgrp\fR(3C), \fBtermios\fR(3C), \fBsignal.h\fR(3HEAD),
2421 \fBstreamio\fR(7I)







   1 .\" Copyright (c) 2005, Sun Microsystems, Inc.  All Rights Reserved.
   2 .\" Copyright 2019, Joyent, Inc.  All Rights Reserved.
   3 .\" Copyright 1989 AT&T
   4 .\" The contents of this file are subject to the terms of the
   5 .\" Common Development and Distribution License (the "License").
   6 .\" You may not use this file except in compliance with the License.
   7 .\"
   8 .\" You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
   9 .\" or http://www.opensolaris.org/os/licensing.
  10 .\" See the License for the specific language governing permissions
  11 .\" and limitations under the License.
  12 .\"
  13 .\" When distributing Covered Code, include this CDDL HEADER in each
  14 .\" file and include the License file at usr/src/OPENSOLARIS.LICENSE.
  15 .\" If applicable, add the following below this CDDL HEADER, with the
  16 .\" fields enclosed by brackets "[]" replaced with your own identifying
  17 .\" information: Portions Copyright [yyyy] [name of copyright owner]
  18 .Dd March 17, 2019
  19 .Dt TERMIO 7I
  20 .Os
  21 .Sh NAME
  22 .Nm termio
  23 .Nd general terminal interface
  24 .Sh SYNOPSIS
  25 .In termio.h
  26 .Fn ioctl "int fildes" "int request" "struct termio *arg"
  27 .Fn ioctl "int fildes" "int request" "int arg"
  28 .Pp
  29 .In termios.h
  30 .Fn ioctl "int fildes" "int request" "struct termios *arg"
  31 .Sh DESCRIPTION
  32 This release supports a general interface for asynchronous communications ports
  33 that is hardware-independent.
  34 The user interface to this functionality is using
  35 function calls (the preferred interface) described in
  36 .Xr termios 3C
  37 or
  38 .Fn ioctl
  39 commands described in this section.
  40 This section also discusses the
  41 common features of the terminal subsystem which are relevant with both user
  42 interfaces.
  43 .Pp

  44 When a terminal file is opened, it normally causes the process to wait until a
  45 connection is established.
  46 In practice, user programs seldom open terminal
  47 files; they are opened by the system and become a user's standard input,
  48 output, and error files.
  49 The first terminal file opened by the session leader
  50 that is not already associated with a session becomes the controlling terminal
  51 for that session.
  52 The controlling terminal plays a special role in handling
  53 quit and interrupt signals, as discussed below.
  54 The controlling terminal is
  55 inherited by a child process during a
  56 .Xr fork 2 .
  57 A process can break this
  58 association by changing its session using
  59 .Xr setsid 2 .
  60 .Pp
  61 A terminal associated with one of these files ordinarily operates in
  62 full-duplex mode.
  63 Characters may be typed at any time, even while output is
  64 occurring, and are only lost when the character input buffers of the system
  65 become completely full, which is rare.
  66 For example, the number of characters in
  67 the line discipline buffer may exceed
  68 .Brq Dv MAX_CANON
  69 and
  70 .Dv IMAXBEL
  71 (see below) is not set, or the user may accumulate
  72 .Brq Dv MAX_INPUT
  73 number of input characters that have not yet been read by some program.
  74 When the input
  75 limit is reached, all the characters saved in the buffer up to that point are
  76 thrown away without notice.
  77 .Ss "Session Management (Job Control)"

  78 A control terminal will distinguish one of the process groups in the session
  79 associated with it to be the foreground process group.
  80 All other process
  81 groups in the session are designated as background process groups.
  82 This foreground process group plays a special role in handling signal-generating
  83 input characters, as discussed below.
  84 By default, when a controlling terminal
  85 is allocated, the controlling process's process group is assigned as
  86 foreground process group.
  87 .Pp

  88 Background process groups in the controlling process's session are subject to a
  89 job control line discipline when they attempt to access their controlling
  90 terminal.
  91 Process groups can be sent signals that will cause them to stop,
  92 unless they have made other arrangements.
  93 An exception is made for members of
  94 orphaned process groups.
  95 .Pp
  96 An orphaned process group is one where the process group (see
  97 .Xr getpgid 2 )
  98 has no members with a parent in a different process group but sharing the same
  99 controlling terminal.
 100 When a member of an orphaned process group attempts to
 101 access its controlling terminal, EIO is returned because there would be no way
 102 to restart the process if it were stopped on one of these signals.
 103 .Pp

 104 If a member of a background process group attempts to read its controlling
 105 terminal, its process group will be sent a
 106 .Dv SIGTTIN
 107 signal, which will
 108 normally cause the members of that process group to stop.
 109 If, however, the
 110 process is ignoring or holding
 111 .Dv SIGTTIN ,
 112 or is a member of an orphaned
 113 process group, the read will fail with
 114 .Va errno
 115 set to
 116 .Er EIO ,
 117 and no signal is sent.
 118 .Pp
 119 If a member of a background process group attempts to write its controlling
 120 terminal and the
 121 .Dv TOSTOP
 122 bit is set in the
 123 .Fa c_lflag
 124 field, its process group is sent a
 125 .Dv SIGTTOU
 126 signal, which will normally cause the
 127 members of that process group to stop.
 128 If, however, the process is ignoring or
 129 holding
 130 .Dv SIGTTOU ,
 131 the write will succeed.
 132 If the process is not ignoring
 133 or holding
 134 .Dv SIGTTOU
 135 and is a member of an orphaned process group, the
 136 write will fail with
 137 .Va errno
 138 set to
 139 .Er EIO ,
 140 and no signal will be sent.
 141 .Pp
 142 If
 143 .Dv TOSTOP
 144 is set and a member of a background process group attempts to
 145 .Fn ioctl
 146 its controlling terminal, and that
 147 .Fn ioctl
 148 will modify terminal parameters (for example,
 149 .Dv TCSETA ,
 150 .Dv TCSETAW ,
 151 .Dv TCSETAF ,
 152 or
 153 .Dv TIOCSPGRP ) ,
 154 its process group will be sent a
 155 .Dv SIGTTOU
 156 signal, which will normally cause the members of that process group to stop.
 157 If, however, the process is ignoring or holding
 158 .Dv SIGTTOU ,
 159 the ioctl will succeed.
 160 If the process is not ignoring or holding
 161 .Dv SIGTTOU
 162 and is a member of an orphaned
 163 process group, the write will fail with
 164 .Va errno
 165 set to
 166 .Er EIO ,
 167 and no signal will be sent.
 168 .Ss "Canonical Mode Input Processing"
 169 Normally, terminal input is processed in units of lines.
 170 A line is delimited by
 171 a newline
 172 .Po
 173 .Sy ASCII LF
 174 .Pc
 175 character, an end-of-file
 176 .Po
 177 .Sy ASCII EOT
 178 .Pc
 179 character, or an end-of-line character.
 180 This means that a program attempting to
 181 read will block until an entire line has been typed.
 182 Also, no matter how many
 183 characters are requested in the read call, at most one line will be returned.
 184 It is not necessary, however, to read a whole line at once; any number of
 185 characters may be requested in a read, even one, without losing information.
 186 .Pp
 187 During input, erase, erase2, and kill processing is normally done.
 188 The
 189 .Sy ERASE
 190 and
 191 .Sy ERASE2
 192 character (by default, the character
 193 .Sy DEL
 194 for
 195 .Sy ERASE
 196 and
 197 .Sy Control-h
 198 for
 199 .Sy ERASE2 )
 200 erases the last character typed.
 201 The
 202 .Sy WERASE
 203 character (the character
 204 .Sy Control-w )
 205 erases the
 206 last "word" typed in the current input line (but not any preceding spaces or
 207 tabs).
 208 A
 209 .Dq word
 210 is defined as a sequence of non-blank characters, with tabs counted as blanks.
 211 None of
 212 .Sy ERASE
 213 or
 214 .Sy ERASE2
 215 or
 216 .Sy WERASE
 217 will erase beyond the beginning of the line.
 218 The
 219 .Sy KILL
 220 character (by default,
 221 the character
 222 .Sy NAK )
 223 kills (deletes) the entire input line, and optionally
 224 outputs a newline character.
 225 All these characters operate on a key stroke basis,
 226 independent of any backspacing or tabbing that may have been done.
 227 The
 228 .Sy REPRINT
 229 character (the character
 230 .Sy Control-r )
 231 prints a newline followed by all characters that have not been read.
 232 Reprinting also occurs automatically if
 233 characters that would normally be erased from the screen are fouled by program
 234 output.
 235 The characters are reprinted as if they were being echoed;
 236 consequencely, if
 237 .Dv ECHO
 238 is not set, they are not printed.
 239 .Pp
 240 The
 241 .Sy ERASE ,
 242 .Sy ERASE2 ,
 243 and
 244 .Sy KILL
 245 characters may be entered literally by preceding them with the escape character.
 246 In this case, the escape character is not read.
 247 The erase, erase2, and kill characters may be changed.
 248 .Ss "Non-canonical Mode Input Processing"
 249 In non-canonical mode input processing, input characters are not assembled into
 250 lines, and erase and kill processing does not occur.
 251 The
 252 .Sy MIN
 253 and
 254 .Sy TIME
 255 values are used to determine how to process the characters received.
 256 .Pp
 257 .Sy MIN
 258 represents the minimum number of characters that should be received
 259 when the read is satisfied (that is, when the characters are returned to the
 260 user).
 261 .Sy TIME
 262 is a timer of 0\&.10-second granularity that is used to timeout
 263 bursty and short-term data transmissions.
 264 The four possible values for
 265 .Sy MIN
 266 and
 267 .Sy TIME
 268 and their interactions are described below.
 269 .Bl -tag -width "Case A: Min > 0, Time > 0"
 270 .It Sy Case A: MIN > 0, TIME > 0
 271 In this case,
 272 .Sy TIME
 273 serves as an intercharacter timer and is activated
 274 after the first character is received.
 275 Since it is an intercharacter timer, it
 276 is reset after a character is received.
 277 The interaction between
 278 .Sy MIN
 279 and
 280 .Sy TIME
 281 is as follows: as soon as one character is received, the
 282 intercharacter timer is started.
 283 If
 284 .Sy MIN
 285 characters are received before
 286 the intercharacter timer expires (note that the timer is reset upon receipt of
 287 each character), the read is satisfied.
 288 If the timer expires before
 289 .Sy MIN
 290 characters are received, the characters received to that point are returned to
 291 the user.
 292 Note that if
 293 .Sy TIME
 294 expires, at least one character will be
 295 returned because the timer would not have been enabled unless a character was
 296 received.
 297 In this case (MIN > 0, TIME > 0), the read sleeps until the
 298 .Sy MIN
 299 and
 300 .Sy TIME
 301 mechanisms are activated by the receipt of the first character.
 302 If the number of characters read is less than the number of characters
 303 available, the timer is not reactivated and the subsequent read is satisfied
 304 immediately.
 305 .It Sy Case B: MIN > 0, TIME = 0
 306 In this case, since the value of
 307 .Sy TIME
 308 is zero, the timer plays no role
 309 and only
 310 .Sy MIN
 311 is significant.
 312 A pending read is not satisfied until
 313 .Sy MIN
 314 characters are received (the pending read sleeps until
 315 .Sy MIN
 316 characters are received).
 317 A program that uses this case to read record based
 318 terminal
 319 .Sy I/O
 320 may block indefinitely in the read operation.
 321 .It Sy Case C: MIN = 0, TIME > 0
 322 In this case, since
 323 .Sy MIN
 324 0,
 325 .Sy TIME
 326 no longer represents an
 327 intercharacter timer: it now serves as a read timer that is activated as soon
 328 as a
 329 .Xr read  2
 330 is done.
 331 A read is satisfied as soon as a single character is
 332 received or the read timer expires.
 333 Note that, in this case, if the timer
 334 expires, no character is returned.
 335 If the timer does not expire, the only way
 336 the read can be satisfied is if a character is received.
 337 In this case, the
 338 read will not block indefinitely waiting for a character; if no character is
 339 received within
 340 .Sy TIME
 341 *\&.10 seconds after the read is initiated, the read
 342 returns with zero characters.
 343 .It Sy Case D: MIN = 0, TIME = 0
 344 In this case, return is immediate.
 345 The minimum of either the number of






 346 characters requested or the number of characters currently available is
 347 returned without waiting for more characters to be input.
 348 .El
 349 .Ss "Comparing Different Cases of MIN, TIME Interaction"
 350 Some points to note about
 351 .Sy MIN
 352 and
 353 .Sy TIME :
 354 .Bl -bullet -offset 2n
 355 .It
 356 In the following explanations, note that the interactions of
 357 .Sy MIN
 358 and
 359 .Sy TIME
 360 are not symmetric.
 361 For example, when
 362 .Sy MIN
 363 > 0 and
 364 .Sy TIME
 365 = 0,
 366 .Sy TIME
 367 has no effect.
 368 However, in the opposite case, where
 369 .Sy MIN
 370 = 0 and
 371 .Sy TIME
 372 > 0, both
 373 .Sy MIN
 374 and
 375 .Sy TIME
 376 play a role in that
 377 .Sy MIN
 378 is satisfied with the receipt of a single character.
 379 .It
 380 Also note that in case A
 381 .Po
 382 .Sy MIN
 383 > 0,
 384 .Sy TIME
 385 > 0
 386 .Pc ,
 387 .Sy TIME
 388 represents
 389 an intercharacter timer, whereas in case C
 390 .Po
 391 .Sy MIN
 392 = 0,
 393 .Sy TIME
 394 > 0
 395 .Pc ,
 396 .Sy TIME
 397 represents a read timer.
 398 .El
 399 .Pp
 400 These two points highlight the dual purpose of the
 401 .Sy MIN/TIME
 402 feature.
 403 Cases A and B, where
 404 .Sy MIN
 405 > 0, exist to handle burst mode activity (for
 406 example, file transfer programs), where a program would like to process at
 407 least
 408 .Sy MIN
 409 characters at a time.
 410 In case A, the inteercharacter timer is
 411 activated by a user as a safety measure; in case B, the timer is turned off.
 412 .Pp
 413 Cases C and D exist to handle single character, timed transfers.
 414 These cases
 415 are readily adaptable to screen-based applications that need to know if a
 416 character is present in the input queue before refreshing the screen.
 417 In case
 418 C, the read is timed, whereas in case D, it is not.
 419 .Pp
 420 Another important note is that
 421 .Sy MIN
 422 is always just a minimum.
 423 It does not
 424 denote a record length.
 425 For example, if a program does a read of 20 bytes,
 426 .Sy MIN
 427 is 10, and 25 characters are present, then 20 characters will be
 428 returned to the user.
 429 .Ss "Writing Characters"

 430 When one or more characters are written, they are transmitted to the terminal
 431 as soon as previously written characters have finished typing.
 432 nputt characters
 433 are echoed as they are typed if echoing has been enabled.
 434 If a process produces
 435 characters more rapidly than they can be typed, it will be suspended when its
 436 output queue exceeds some limit.
 437 When the queue is drained down to some
 438 threshold, the program is resumed.
 439 .Ss "Special Characters"
 440 Certain characters have special functions on input.
 441 These functions and their default character values are summarized as follows:
 442 .Bl -tag -width REPRINT
 443 .It Sy INTR
 444 (Control-c or
 445 .Sy ASCII ETX )
 446 generates a
 447 .Dv SIGINT
 448 signal.
 449 .Dv SIGINT
 450 is sent to all foreground processes associated with the controlling terminal.
 451 Normally, each such process is forced to terminate, but arrangements may be
 452 made either to ignore the signal or to receive a trap to an agreed upon
 453 location.
 454 (See
 455 .Xr signal.h 3HEAD ) .
 456 .It Sy QUIT
 457 (Control-| or
 458 .Sy ASCII FS )
 459 generates a
 460 .Dv SIGQUIT
 461 signal.
 462 Its treatment
 463 is identical to the interrupt signal except that, unless a receiving process
 464 has made other arrangements, it will not only be terminated but a core image
 465 file (called
 466 .Pa core )
 467 will be created in the current working directory.
 468 .It Sy ERASE
 469 (DEL) erases the preceding character.
 470 It does not erase beyond
 471 the start of a line, as delimited by a
 472 .Sy NL ,
 473 .Sy EOF ,
 474 .Sy EOL ,
 475 or
 476 .Sy EOL2
 477 character.
 478 .It Sy ERASE2
 479 (Control-h or
 480 .Sy ASCII BS )
 481 erases the preceding character, with behaviour identical to that of ERASE.
 482 .It Sy WERASE
 483 (Control-w or
 484 .Sy ASCII ETX )
 485 erases the preceding
 486 .Dq word .
 487 It does not erase beyond the start of a line, as delimited by a
 488 .Sy NL ,
 489 .Sy EOF ,
 490 .Sy EOL ,
 491 or
 492 .Sy EOL2
 493 character.
 494 .It Sy KILL
 495 (Control-u or
 496 .Sy ASCII NAK )
 497 deletes the entire line, as delimited by a
 498 .Sy NL ,
 499 .Sy EOF ,
 500 .Sy EOL ,
 501 or
 502 .Sy EOL2
 503 character.
 504 .It Sy REPRINT
 505 (Control-r or
 506 .Sy ASCII DC2 )
 507 reprints all characters, preceded by a newline, that have not been read.
 508 .It Sy EOF
 509 (Control-d or
 510 .Sy ASCII EOT )
 511 may be used to generate an end-of-file from a terminal.
 512 When received, all the characters waiting to be read are immediately
 513 passed to the program, without waiting for a newline, and the
 514 .Sy EOF
 515 is discarded.
 516 Thus, if no characters are waiting (that is, the
 517 .Sy EOF
 518 occurred











 519 at the beginning of a line) zero characters are passed back, which is the
 520 standard end-of-file indication.
 521 Unless escaped, the
 522 .Sy EOF
 523 character is not
 524 echoed.
 525 Because
 526 .Sy EOT
 527 is the default
 528 .Sy EOF
 529 character, this prevents
 530 terminals that respond to
 531 .Sy EOT
 532 from hanging up.
 533 .It Sy NL
 534 .Pq Sy ASCII LF
 535 is the normal line delimiter.
 536 It cannot be changed or escaped.
 537 .It Sy EOL
 538 .Pq Sy ASCII NULL
 539 is an additional line delimiter, like
 540 .Sy NL .
 541 It is not normally used.
 542 .It Sy EOL2







 543 is another additional line delimiter.
 544 .It Sy SWTCH
 545 (Control-z or
 546 .Sy ASCII EM )
 547 Header file symbols related to this special





 548 character are present for compatibility purposes only and the kernel takes no
 549 special action on matching SWTCH (except to discard the character).
 550 .It Sy SUSP
 551 (Control-z or
 552 .Sy ASCII SUB )
 553 generates a
 554 .Dv SIGTSTP
 555 signal.
 556 .Dv SIGTSTP


 557 stops all processes in the foreground process group for that terminal.
 558 .It Sy DSUSP
 559 (Control-y or
 560 .Sy ASCII EM ) .
 561 It generates a
 562 .Dv SIGTSTP
 563 signal as
 564 .Sy SUSP
 565 does, but the signal is sent when a process in the foreground
 566 process group attempts to read the
 567 .Sy DSUSP
 568 character, rather than when it is typed.
 569 .It Sy STOP
 570 (Control-s or
 571 .Sy ASCII DC3 )
 572 can be used to suspend output temporarily.
 573 It is useful with
 574 .Sy CRT
 575 terminals to prevent output from disappearing before it can be read.
 576 While output is suspended,
 577 .Sy STOP
 578 characters are ignored and


 579 not read.
 580 .It Sy START
 581 (Control-q or
 582 .Sy ASCII DC1 )
 583 is used to resume output.
 584 Output has been suspended by a
 585 .Sy STOP
 586 character.
 587 While output is not suspended,
 588 .Sy START
 589 characters are ignored and not read.
 590 .It Sy DISCARD
 591 (Control-o or
 592 .Sy ASCII SI )
 593 causes subsequent output to be discarded.
 594 Output is discarded until another
 595 .Sy DISCARD
 596 character is typed, more input




 597 arrives, or the condition is cleared by a program.
 598 .It Sy STATUS
 599 (Control-t or
 600 .Sy ASCII DC4 )
 601 generates a
 602 .Dv SIGINFO
 603 signal.
 604 Processes with a handler will output status information when they receive
 605 .Dv SIGINFO ,
 606 for
 607 example,
 608 .Xr dd 1M .
 609 If a process does not have a
 610 .Dv SIGINFO
 611 handler, the
 612 signal will be ignored.
 613 .It Sy LNEXT
 614 (Control-v or
 615 .Sy ASCII SYN )
 616 causes the special meaning of the next character to be ignored.
 617 This works for all the special characters mentioned above.
 618 It




 619 allows characters to be input that would otherwise be interpreted by the system
 620 (for example
 621 .Sy KILL ,
 622 .Sy QUIT ) .
 623 The character values for
 624 .Sy INTR ,
 625 .Sy QUIT ,
 626 .Sy ERASE ,
 627 .Sy ERASE2 ,
 628 .Sy WERASE ,
 629 .Sy KILL ,
 630 .Sy REPRINT ,
 631 .Sy EOF ,
 632 .Sy EOL ,
 633 .Sy EOL2 ,
 634 .Sy SWTCH ,
 635 .Sy SUSP ,
 636 .Sy DSUSP ,
 637 .Sy STOP ,
 638 .Sy START ,
 639 .Sy DISCARD ,
 640 .Sy STATUS ,
 641 and
 642 .Sy LNEXT
 643 may be changed to suit individual tastes.
 644 If the value of a special control character
 645 is
 646 .Dv _POSIX_VDISABLE
 647 (0), the function of that special control character is disabled.
 648 The
 649 .Sy ERASE ,
 650 .Sy ERASE2 ,
 651 .Sy KILL ,
 652 and
 653 .Sy EOF
 654 characters may be
 655 escaped by a preceding backslash (\e) character, in which case no special
 656 function is done.
 657 Any of the special characters may be preceded by the
 658 .Sy LNEXT
 659 character, in
 660 which case no special function is done.
 661 .El
 662 .Ss "Modem Disconnect"
 663 When a modem disconnect is detected, a
 664 .Dv SIGHUP
 665 signal is sent to the
 666 terminal's controlling process.
 667 Unless other arrangements have been made, these
 668 signals cause the process to terminate.
 669 If
 670 .Dv SIGHUP
 671 is ignored or caught,
 672 any subsequent read returns with an end-of-file indication until the terminal
 673 is closed.
 674 .Pp

 675 If the controlling process is not in the foreground process group of the
 676 terminal, a
 677 .Dv SIGTSTP
 678 is sent to the terminal's foreground process group.
 679 Unless other arrangements have been made, these signals cause the processes to
 680 stop.
 681 .Pp

 682 Processes in background process groups that attempt to access the controlling
 683 terminal after modem disconnect while the terminal is still allocated to the
 684 session will receive appropriate
 685 .Dv SIGTTOU
 686 and
 687 .Dv SIGTTIN
 688 signals.
 689 Unless other arrangements have been made, this signal causes the processes to
 690 stop.
 691 .Pp

 692 The controlling terminal will remain in this state until it is reinitialized
 693 ithh a successful open by the controlling process, or deallocated by the
 694 controlling process.
 695 .Ss "Terminal Parameters"

 696 The parameters that control the behavior of devices and modules providing the
 697 .Vt termios
 698 interface are specified by the
 699 .Vt termios
 700 structure defined by
 701 .In termios.h .
 702 Several
 703 .Xr ioctl 2
 704 system calls that fetch or change
 705 these parameters use this structure that contains the following members:
 706 .Bd -literal -offset 2n
 707 tcflag_t        c_iflag;        /* input modes */
 708 tcflag_t        c_oflag;        /* output modes */
 709 tcflag_t        c_cflag;        /* control modes */
 710 tcflag_t        c_lflag;        /* local modes */
 711 cc_t            c_cc[NCCS];     /* control chars */
 712 .Ed
 713 .Pp
 714 The special control characters are defined by the array
 715 .Fa c_cc .
 716 The symbolic name
 717 .Dv NCCS
 718 is the size of the Control-character array and is also
 719 defined by
 720 .In termios.h .
 721 The relative positions, subscript names, and
 722 typical default values for each function are as follows:
 723 .Bl -column "Relative Position" "Subscript Name" "Typical Default Value"
 724 .It Relative Position Ta Subscript Name Ta Typical Default Value
 725 .It 0 Ta Dv VINTR Ta Sy ETX
 726 .It 1 Ta Dv VQUIT Ta Sy FS
 727 .It 2 Ta Dv VERASE Ta Sy DEL
 728 .It 3 Ta Dv VKILL Ta Sy NAK
 729 .It 4 Ta Dv VEOF Ta Sy EOT
 730 .It 5 Ta Dv VEOL Ta Sy NUL
 731 .It 6 Ta Dv VEOL2 Ta Sy NUL
 732 .It 7 Ta Dv VWSTCH Ta Sy NUL
 733 .It 8 Ta Dv VSTART Ta Sy NUL
 734 .It 9 Ta Dv VSTOP Ta Sy DC3
 735 .It 10 Ta Dv VSUSP Ta Sy SUB
 736 .It 11 Ta Dv VDSUSP Ta Sy EM
 737 .It 12 Ta Dv VREPRINT Ta Sy DC2
 738 .It 13 Ta Dv VDISCARD Ta Sy SI
 739 .It 14 Ta Dv VWERASE Ta Sy ETB
 740 .It 15 Ta Dv VLNEXT Ta Sy SYN
 741 .It 16 Ta Dv VSTATUS Ta Sy DC4
 742 .It 17 Ta Dv VERASE2 Ta Sy BS
 743 .It 18-19 Ta Reserved Ta
 744 .El
 745 .Ss "Input Modes"
 746 The
 747 .Fa c_iflag
 748 field describes the basic terminal input control:
 749 .Pp
 750 .Bl -tag -width "IMAXBEL" -offset 2n -compact
 751 .It Dv IGNBRK
 752 Ignore break condition.
 753 .It Dv BRKINT



































 754 Signal interrupt on break.
 755 .It Dv IGNPAR







 756 Ignore characters with parity errors.
 757 .It Dv PARMRK







 758 Mark parity errors.
 759 .It Dv INPCK







 760 Enable input parity check.
 761 .It Dv ISTRIP







 762 Strip character.
 763 .It Dv INLCR







 764 Map NL to CR on input.
 765 .It Dv IGNCR







 766 Ignore CR.
 767 .It Dv ICRNL







 768 Map CR to NL on input.
 769 .It Dv IUCLC







 770 Map upper-case to lower-case on input.
 771 .It Dv IXON







 772 Enable start/stop output control.
 773 .It Dv IXANY







 774 Enable any character to restart output.
 775 .It Dv IXOFF







 776 Enable start/stop input control.
 777 .It Dv IMAXBEL
 778 Echo
 779 .Sy BEL
 780 on input line too long.
 781 .El
 782 .Pp
 783 If
 784 .Dv IGNBRK
 785 is set, a break condition (a character framing error with data





 786 all zeros) detected on input is ignored, that is, not put on the input queue
 787 and therefore not read by any process.
 788 If
 789 .Dv IGNBRK
 790 is not set and
 791 .Dv BRKINT
 792 is set, the break condition shall flush the input and output
 793 queues and if the terminal is the controlling terminal of a foreground process
 794 group, the break condition generates a single
 795 .Dv SIGINT
 796 signal to that
 797 foreground process group.
 798 If neither
 799 .Dv IGNBRK
 800 nor
 801 .Dv BRKINT
 802 is set, a
 803 break condition is read as a single
 804 .Ql \e0
 805 .Pq Sy ASCII NULL
 806 character, or if
 807 .Dv PARMRK
 808 is set, as
 809 .Ql \e377 ,
 810 .Ql \e0 ,
 811 .Em c ,
 812 where
 813 .Ql \e377
 814 is a single character
 815 with value 377 octal (0xff hex, 255 decimal),
 816 .Ql \e0
 817 is a single character with value
 818 .Sy 0 ,
 819 and
 820 .Em c
 821 is the errored character received.
 822 .Pp
 823 If
 824 .Dv IGNPAR
 825 is set, a byte with framing or parity errors (other than
 826 break) is ignored.
 827 .Pp
 828 If
 829 .Dv PARMRK
 830 is set, and
 831 .Dv IGNPAR
 832 is not set, a byte with a framing or
 833 parity error (other than break) is given to the application as the
 834 three-character sequence:
 835 .Ql \e377 ,
 836 .Ql \e0 ,
 837 c, where
 838 .Ql \e377
 839 is a single character with value 377 octal (0xff hex, 255 decimal),
 840 .Ql \e0
 841 is a single character with value 0, and c is the errored character received.
 842 To avoid ambiguity in this case, if
 843 .Dv ISTRIP
 844 is not set, a valid character
 845 of
 846 .Ql \e377
 847 is given to the application as
 848 .Ql \e377 .
 849 If neither
 850 .Dv IGNPAR
 851 nor
 852 .Dv PARMRK
 853 is set, a framing or parity error (other than break) is given to
 854 the application as a single
 855 .Ql \e0
 856 .Po
 857 .Sy ASCII NULL
 858 .Pc
 859 character.
 860 .Pp
 861 If
 862 .Dv INPCK
 863 is set, input parity checking is enabled.
 864 If
 865 .Dv INPCK
 866 is not
 867 set, input parity checking is disabled.
 868 This allows output parity generation
 869 without input parity errors.
 870 Note that whether input parity checking is
 871 enabled or disabled is independent of whether parity detection is enabled or
 872 disabled.
 873 If parity detection is enabled but input parity checking is
 874 disabled, the hardware to which the terminal is connected will recognize the
 875 parity bit, but the terminal special file will not check whether this is set
 876 correctly or not.
 877 .Pp
 878 If
 879 .Dv ISTRIP
 880 is set, valid input characters are first stripped to seven
 881 bits, otherwise all eight bits are processed.
 882 .Pp
 883 If
 884 .Dv INLCR
 885 is set, a received
 886 .Sy NL
 887 character is translated into a
 888 .Sy CR
 889 character.
 890 If
 891 .Dv IGNCR
 892 is set, a received
 893 .Sy CR
 894 character is ignored (not read).
 895 Otherwise, if
 896 .Dv ICRNL
 897 is set, a received
 898 .Sy CR
 899 character is translated into a
 900 .Sy NL
 901 character.
 902 .Pp
 903 If
 904 .Dv IUCLC
 905 is set, a received upper case, alphabetic character is
 906 translated into the corresponding lower case character.
 907 .Pp
 908 If
 909 .Dv IXON
 910 is set, start/stop output control is enabled.
 911 A received
 912 .Sy STOP
 913 character suspends output and a received
 914 .Sy START
 915 character
 916 restarts output.
 917 The
 918 .Sy STOP
 919 and
 920 .Sy START
 921 characters will not be read,
 922 but will merely perform flow control functions.
 923 If
 924 .Dv IXANY
 925 is set, any
 926 input character restarts output that has been suspended.
 927 .Pp
 928 If
 929 .Dv IXOFF
 930 is set, the system transmits a
 931 .Sy STOP
 932 character when the
 933 input queue is nearly full, and a
 934 .Sy START
 935 character when enough input has
 936 been read so that the input queue is nearly empty again.
 937 .Pp
 938 If
 939 .Dv IMAXBEL
 940 is set, the
 941 .Sy ASCII BEL
 942 character is echoed if the input stream overflows.
 943 Further input is not stored, but any input already present in
 944 the input stream is not disturbed.
 945 If
 946 .Dv IMAXBEL
 947 is not set, no
 948 .Sy BEL
 949 character is echoed, and all input present in the input queue is discarded if
 950 the input stream overflows.
 951 .Ss "Output Modes"
 952 The
 953 .Fa c_oflag
 954 field specifies the system treatment of output:
 955 .Pp
 956 .Bl -tag -width ONLRET -offset 2n -compact
 957 .It Dv OPOST


 958 Post-process output.
 959 .It Dv OLCUC







 960 Map lower case to upper on output.
 961 .It Dv ONLCR







 962 Map NL to CR-NL on output.
 963 .It Dv OCRNL







 964 Map CR to NL on output.
 965 .It Dv ONOCR
 966 No
 967 .Sy CR
 968 output at column 0.
 969 .It Dv ONLRET
 970 .Sy NL
 971 performs
 972 .Sy CR
 973 function.
 974 .It Dv OFILL
















 975 Use fill characters for delay.
 976 .It Dv OFDEL
 977 Fill is
 978 .Sy DEL ,
 979 else
 980 .Sy INULL .
 981 .It Dv NLDLY











 982 Select newline delays:
 983 .Bl -tag -width NL0 -compact -offset 2n
 984 .It Sy NL0
 985 .It Sy NL1
 986 .El
 987 .It Dv CRDLY











 988 Select carriage-return delays:
 989 .Bl -tag -width CR0 -compact -offset 2n
 990 .It Dv CR0
 991 .It Dv CR1
 992 .It Dv CR2
 993 .It Dv CR3
 994 .El
 995 .It Dv TABDLY

















 996 Select horizontal tab delays or tab expansion:
 997 .Bl -tag -width XTABS -compact -offset 2n
 998 .It Dv TAB0
 999 .It Dv TAB1
1000 .It Dv TAB2
1001 .It Dv TAB3




























1002 Expand tabs to spaces
1003 .It Dv XTABS







1004 Expand tabs to spaces
1005 .El
1006 .It Dv BSDLY








1007 Select backspace delays:
1008 .Bl -tag -width BS0 -offset 2n -compact
1009 .It Dv BS0
1010 .It Dv BS1
1011 .El
1012 .It Dv VTDLY











1013 Select vertical tab delays:
1014 .Bl -tag -width VT0 -offset 2n -compact
1015 .It Dv VT0
1016 .It Dv VT1
1017 .El
1018 .It Dv FFDLY











1019 Select form feed delays:
1020 .Bl -tag -width FF0 -offset 2n -compact
1021 .It Dv FF0
1022 .It Dv FF1
1023 .El
1024 .El
1025 .Pp
1026 If
1027 .Dv OPOST
1028 is set, output characters are post-processed as indicated by the




1029 remaining flags; otherwise, characters are transmitted without change.
1030 .Pp
1031 If
1032 .Dv OLCUC
1033 is set, a lower case alphabetic character is transmitted as the
1034 corresponding upper case character.
1035 This function is often used in conjunction
1036 with
1037 .Dv IUCLC .
1038 .Pp
1039 If
1040 .Dv ONLCR
1041 is set, the
1042 .Sy NL
1043 character is transmitted as the
1044 .Sy CR-NL
1045 character pair.
1046 If
1047 .Dv OCRNL
1048 is set, the
1049 .Sy CR
1050 character is transmitted as the
1051 .Sy NL
1052 character.
1053 If
1054 .Dv ONOCR
1055 is set, no
1056 .Sy CR
1057 character is transmitted when at column 0 (first position).
1058 If
1059 .Dv ONRET
1060 is set, the
1061 .Sy NL
1062 character is assumed to do the carriage-return function; the column
1063 pointer is set to 0 and the delays specified for
1064 .Sy CR
1065 are used.
1066 Otherwise, the
1067 .Sy NL
1068 character is assumed to do just the line-feed function; the column
1069 pointer remains unchanged.
1070 The column pointer is also set to 0 if the
1071 .Sy CR
1072 character is actually transmitted.
1073 .Pp

1074 The delay bits specify how long transmission stops to allow for mechanical or
1075 other movement when certain characters are sent to the terminal.
1076 In all cases, a value of 0 indicates no delay.
1077 If
1078 .Dv OFILL
1079 is set, fill characters are transmitted for delay instead of a timed delay.
1080 This is useful for high baud rate terminals that need only a minimal delay.
1081 If
1082 .Dv OFDEL
1083 is set, the
1084 fill character is
1085 .Sy DEL ;
1086 otherwise it is
1087 .Sy NULL .
1088 .Pp
1089 If a form-feed or vertical-tab delay is specified, it lasts for about 2
1090 seconds.
1091 .Pp
1092 Newline delay lasts about 0\&.10 seconds.
1093 If
1094 .Dv ONLRET
1095 is set, the carriage-return delays are used instead of the newline delays.
1096 If
1097 .Dv OFILL
1098 is set, two fill characters are transmitted.
1099 .Pp

1100 Carriage-return delay type 1 is dependent on the current column position, type
1101 2 is about 0\&.10 seconds, and type 3 is about 0\&.15 seconds.
1102 If
1103 .Dv OFILL
1104 is set, delay type 1 transmits two fill characters, and type 2 transmits four
1105 fill characters.
1106 .Pp
1107 Horizontal-tab delay type 1 is dependent on the current column position.
1108 Type 2 is about 0\&.10 seconds.
1109 Type 3 specifies that tabs are to be expanded into spaces.
1110 If
1111 .Dv OFILL
1112 is set, two fill characters are transmitted for any delay.
1113 .Pp
1114 Backspace delay lasts about 0\&.05 seconds.
1115 If
1116 .Dv OFILL
1117 is set, one fill character is transmitted.
1118 .Pp
1119 The actual delays depend on line speed and system load.
1120 .Ss "Control Modes"
1121 The
1122 .Fa c_cflag
1123 field describes the hardware control of the terminal:
1124 .Bl -tag -width CIBAUDEXT -offset 2n
1125 .It Dv CBAUD



1126 Baud rate:
1127 .Bl -tag -width B460800 -compact
1128 .It Dv B0






1129 Hang up
1130 .It Dv B50







1131 50 baud
1132 .It Dv B75







1133 75 baud
1134 .It Dv B110







1135 110 baud
1136 .It Dv B134







1137 134 baud
1138 .It Dv B150







1139 150 baud
1140 .It Dv B200







1141 200 baud
1142 .It Dv B300







1143 300 baud
1144 .It Dv B600







1145 600 baud
1146 .It Dv B1200







1147 1200 baud
1148 .It Dv B1800







1149 1800 baud
1150 .It Dv B2400







1151 2400 baud
1152 .It Dv B4800







1153 4800 baud
1154 .It Dv B9600







1155 9600 baud
1156 .It Dv B19200







1157 19200 baud
1158 .It Dv EXTA







1159 External A
1160 .It Dv B38400







1161 38400 baud
1162 .It Dv EXTB







1163 External B
1164 .It Dv B57600







1165 57600 baud
1166 .It Dv B76800







1167 76800 baud
1168 .It Dv B115200







1169 115200 baud
1170 .It Dv B153600







1171 153600 baud
1172 .It Dv B230400







1173 230400 baud
1174 .It Dv B307200







1175 307200 baud
1176 .It Dv B460800







1177 460800 baud
1178 .El
1179 .It Dv CSIZE






1180 Character size:
1181 .Bl -tag -width CIBAUDEXT -compact
1182 .It Dv CS5






1183 5 bits
1184 .It Dv CS6







1185 6 bits
1186 .It Dv CS7







1187 7 bits
1188 .It Dv CS8







1189 8 bits
1190 .It Dv CSTOPB







1191 Send two stop bits, else one
1192 .It Dv CREAD







1193 Enable receiver
1194 .It Dv PARENB







1195 Parity enable
1196 .It Dv PARODD







1197 Odd parity, else even
1198 .It Dv HUPCL







1199 Hang up on last close
1200 .It Dv CLOCAL







1201 Local line, else dial-up
1202 .It Dv CIBAUD







1203 Input baud rate, if different from output rate
1204 .It Dv PAREXT







1205 Extended parity for mark and space parity
1206 .It Dv CRTSXOFF







1207 Enable inbound hardware flow control
1208 .It Dv CRTSCTS







1209 Enable outbound hardware flow control
1210 .It Dv CBAUDEXT







1211 Bit to indicate output speed > B38400
1212 .It Dv CIBAUDEXT







1213 Bit to indicate input speed > B38400
1214 .El
1215 .El
1216 .Pp
1217 The
1218 .Dv CBAUD
1219 bits together with the
1220 .Dv CBAUDEXT
1221 bit specify the output baud rate.
1222 To retrieve the output speed from the
1223 .Vt termios
1224 structure pointed to by
1225 .Fa termios_p
1226 see the following code segment.
1227 .Bd -literal -offset 2n
1228 speed_t ospeed;
1229 if (termios_p->c_cflag & CBAUDEXT)
1230  ospeed = (termios_p->c_cflag & CBAUD) + CBAUD + 1;
1231 else
1232  ospeed = termios_p->c_cflag & CBAUD;
1233 .Ed
1234 .Pp



1235 To store the output speed in the termios structure pointed to by
1236 .Fa termios_p
1237 see the following code segment.
1238 .Bd -literal -offset 2n

1239 speed_t ospeed;
1240 if (ospeed > CBAUD) {
1241  termios_p->c_cflag |= CBAUDEXT;
1242  ospeed -= (CBAUD + 1);
1243 } else {
1244  termios_p->c_cflag &= ~CBAUDEXT;
1245 }
1246 termios_p->c_cflag =
1247   (termios_p->c_cflag & ~CBAUD) | (ospeed & CBAUD);
1248 .Ed
1249 .Pp
1250 The zero baud rate,
1251 .Dv B0 ,
1252 is used to hang up the connection.
1253 If
1254 .Dv B0
1255 is specified, the data-terminal-ready signal is not asserted.
1256 Normally, this disconnects the line.
1257 .Pp
1258 If the
1259 .Dv CIBAUDEXT
1260 or
1261 .Dv CIBAUD
1262 bits are not zero, they specify the input baud rate, with the
1263 .Dv CBAUDEXT
1264 and
1265 .Dv CBAUD
1266 bits specifying the output baud rate; otherwise, the output and input baud
1267 rates are both specified by the
1268 .Dv CBAUDEXT
1269 and
1270 .Dv CBAUD
1271 bits.
1272 The values for the
1273 .Dv CIBAUD
1274 bits are the same as the values for the
1275 .Dv CBAUD
1276 bits, shifted left
1277 .Dv IBSHIFT
1278 bits.
1279 For any particular hardware, impossible speed changes are
1280 ignored.
1281 To retrieve the input speed in the
1282 .Vt termios
1283 structure pointed to
1284 by
1285 .Fa termios_p
1286 see the following code segment.
1287 .Bd -literal -offset 2n
1288 speed_t ispeed;
1289 if (termios_p->c_cflag & CIBAUDEXT) {
1290  ispeed = ((termios_p->c_cflag & CIBAUD) >> IBSHIFT)
1291  + (CIBAUD >> IBSHIFT) + 1;
1292 } else {
1293  ispeed = (termios_p->c_cflag & CIBAUD) >> IBSHIFT;
1294 }
1295 .Ed
1296 .Pp
1297 To store the input speed in the
1298 .Vt termios
1299 structure pointed to by
1300 .Fa termios_p
1301 see the following code segment.
1302 .Bd -literal -offset 2n

1303 speed_t ispeed;
1304 if (ispeed == 0) {
1305  ispeed = termios_p->c_cflag & CBAUD;
1306  if (termios_p->c_cflag & CBAUDEXT)
1307      ispeed += (CBAUD + 1);
1308 }
1309 if ((ispeed << IBSHIFT) > CIBAUD) {
1310   termios_p->c_cflag |= CIBAUDEXT;
1311   ispeed -= ((CIBAUD >> IBSHIFT) + 1);
1312 } else {
1313   termios_p->c_cflag &= ~CIBAUDEXT;
1314 }
1315 termios_p->c_cflag =
1316   (termios_p->c_cflag & ~CIBAUD) | ((ispeed << IBSHIFT) & CIBAUD);
1317 .Ed
1318 .Pp
1319 The
1320 .Dv CSIZE
1321 bits specify the character size in bits for both transmission and reception.
1322 This size does not include the parity bit, if any.
1323 If
1324 .Dv CSTOPB
1325 is set, two stop bits are used; otherwise, one stop bit is used.
1326 For example, at 110 baud, two stops bits are required.
1327 .Pp
1328 If
1329 .Dv PARENB
1330 is set, parity generation and detection is enabled, and a
1331 parity bit is added to each character.
1332 If parity is enabled, the
1333 .Dv PARODD
1334 flag specifies odd parity if set; otherwise, even parity is used.
1335 .Pp
1336 If
1337 .Dv CREAD
1338 is set, the receiver is enabled.
1339 Otherwise, no characters are received.
1340 .Pp
1341 If
1342 .Dv HUPCL
1343 is set, the line is disconnected when the last process with the
1344 line open closes it or terminates.
1345 That is, the data-terminal-ready signal is not asserted.
1346 .Pp
1347 If
1348 .Dv CLOCAL
1349 is set, the line is assumed to be a local, direct connection
1350 with no modem control; otherwise, modem control is assumed.
1351 .Pp
1352 If
1353 .Dv CRTSXOFF
1354 is set, inbound hardware flow control is enabled.
1355 .Pp
1356 If
1357 .Dv CRTSCTS
1358 is set, outbound hardware flow control is enabled.
1359 .Pp
1360 The four possible combinations for the state of
1361 .Dv CRTSCTS
1362 and
1363 .Dv CRTSXOFF
1364 bits and their interactions are described below.
1365 .Bl -tag -width "Case C:"
1366 .It Sy Case A :
1367 .Dv CRTSCTS
1368 off,
1369 .Dv CRTSXOFF
1370 off.
1371 In this case the hardware flow control is disabled.
1372 .It Sy Case B :
1373 .Dv CRTSCTS
1374 on,
1375 .Dv CRTSXOFF
1376 off.
1377 In this case only outbound hardware flow control is enabled.
1378 The state of CTS signal is used to do outbound flow control.
1379 It is expected that output will be suspended if CTS is low and resumed
1380 when CTS is high.
1381 .It Sy Case C :
1382 .Dv CRTSCTS
1383 off,
1384 .Dv CRTSXOFF
1385 on.
1386 In this case only inbound hardware flow control is enabled.
1387 The state of RTS signal is used to do inbound flow control.



1388 It is expected that input will be suspended if RTS is low and resumed when RTS
1389 is high.
1390 .It Sy Case D :
1391 .Dv CRTSCTS
1392 on,
1393 .Dv CRTSXOFF
1394 on.
1395 In this case both inbound and outbound hardware flow control are enabled.
1396 Uses the state of CTS signal to do outbound



1397 flow control and RTS signal to do inbound flow control.
1398 .El
1399 .Ss "Local Modes"
1400 The
1401 .Fa c_lflag
1402 field of the argument structure is used by the line
1403 discipline to control terminal functions.
1404 The basic line discipline provides the following:
1405 .Pp
1406 .Bl -tag -offset 2n -width SIGTTOU -compact
1407 .It Dv ISIG
1408 Enable signals.
1409 .It Dv ICANON










1410 Canonical input (erase and kill processing).
1411 .It Dv XCASE







1412 Canonical upper/lower presentation.
1413 .It Dv ECHO







1414 Enable echo.
1415 .It Dv ECHOE
1416 Echo erase character as
1417 .Sy BS Ns - Ns Sy SP Ns - Ns Sy BS
1418 &.
1419 .It Dv ECHOK
1420 Echo
1421 .Sy NL
1422 after kill character.
1423 .It Dv ECHONL
1424 Echo
1425 .Sy NL .
1426 .It Dv NOFLSH























1427 Disable flush after interrupt or quit.
1428 .It Dv TOSTOP
1429 Send
1430 .It Dv SIGTTOU
1431 for background output.
1432 .It Dv ECHOCTL
1433 Echo control characters as
1434 .Em char ,
1435 delete as ^?.
1436 .It Dv ECHOPRT

















1437 Echo erase character as character erased.
1438 .It Dv ECHOKE
1439 .Sy BS Ns - Ns Sy SP Ns - Ns Sy BS
1440 erase entire line on line kill.
1441 .It Dv FLUSHO













1442 Output is being flushed.
1443 .It Dv PENDIN







1444 Retype pending input at next read or input character.
1445 .It Dv IEXTEN







1446 Enable extended (implementation-defined) functions.
1447 .El
1448 .Pp
1449 If
1450 .Dv ISIG
1451 is set, each input character is checked against the special
1452 control characters
1453 .Sy INTR ,
1454 .Sy QUIT ,
1455 .Sy SWTCH ,
1456 .Sy SUSP ,
1457 .Sy STATUS ,
1458 and
1459 .Sy DSUSP .
1460 If an input character matches one of these control characters, the function
1461 associated with that character is performed.
1462 .Po
1463 Note: If
1464 .Sy SWTCH
1465 is set and the character matches, the character is simply discarded.
1466 No other action is taken.
1467 .Pc
1468 If
1469 .Dv ISIG
1470 is not set, no checking is done.
1471 Thus, these special
1472 input functions are possible only if
1473 .Dv ISIG
1474 is set.
1475 .Pp
1476 If
1477 .Dv ICANON
1478 is set, canonical processing is enabled.
1479 This enables the erase
1480 and kill edit functions, and the assembly of input characters into lines
1481 delimited by
1482 .Sy NL-c ,
1483 .Sy EOF ,
1484 .Sy EOL ,
1485 and
1486 .Sy EOL .
1487 If
1488 .Dv ICANON
1489 is not set, read requests are satisfied directly from the input queue.
1490 A read is not satisfied until at least
1491 .Sy MIN
1492 characters have been received or the timeout value
1493 .Sy TIME
1494 has expired between characters.
1495 This allows fast bursts of input to be read efficiently while still allowing
1496 single character input.
1497 The time value represents tenths of seconds.
1498 .Pp
1499 If
1500 .Dv XCASE
1501 is set and
1502 .Dv ICANON
1503 is set, an upper case letter is
1504 accepted on input if preceded by a backslash
1505 .Ql \e
1506 character, and is output preceded by a backslash
1507 .Ql \e
1508 character.
1509 In this mode, the
1510 following escape sequences are generated on output and accepted on input:
1511 .Bl -column "FOR:" "USE:" -offset 2n
1512 .It FOR: Ta USE:
1513 .It ` Ta \e'
1514 .It | Ta \e!
1515 .It \(ap Ta \e^
1516 .It { Ta \e(
1517 .It } Ta \e)
1518 .It \e Ta \e\e
1519 .El
1520 .Pp














1521 For example, input A as \ea, \en as \e\en, and \eN as \e\e\en.
1522 .Pp
1523 If
1524 .Dv ECHO
1525 is set, characters are echoed as received.
1526 .Pp
1527 When
1528 .Dv ICANON
1529 is set, the following echo functions are possible.
1530 .Bl -bullet -offset indent
1531 .It
1532 If
1533 .Dv ECHO
1534 and
1535 .Dv ECHOE
1536 are set, and
1537 .Dv ECHOPRT
1538 is not set, the
1539 .Sy ERASE ,
1540 .Sy ERASE2 ,
1541 and
1542 .Sy WERASE
1543 characters are echoed as one or
1544 more ASCII BS SP BS, which clears the last character(s) from a
1545 .Sy CRT
1546 screen.
1547 .It
1548 If
1549 .Dv ECHO ,
1550 .Dv ECHOPRT ,
1551 and
1552 .Dv IEXTEN
1553 are set, the first
1554 .Sy ERASE ,
1555 .Sy ERASE2 ,
1556 and
1557 .Sy WERASE
1558 character in a sequence echoes as a backslash
1559 .Ql \e ,
1560 followed by the characters being erased.
1561 Subsequent
1562 .Sy ERASE
1563 and
1564 .Sy WERASE
1565 characters echo the characters being erased, in reverse order.
1566 The
1567 next non-erase character causes a
1568 .Ql /
1569 (slash) to be typed before it is echoed.
1570 .Dv ECHOPRT
1571 should be used for hard copy terminals.
1572 .It
1573 If
1574 .Dv ECHOKE
1575 and
1576 .Dv IEXTEN
1577 are set, the kill character is echoed by
1578 erasing each character on the line from the screen (using the mechanism
1579 selected by
1580 .Dv ECHOE
1581 and
1582 .Dv ECHOPR ) .
1583 .It
1584 If
1585 .Dv ECHOK
1586 is set, and
1587 .Dv ECHOKE
1588 is not set, the
1589 .Sy NL
1590 character is
1591 echoed after the kill character to emphasize that the line is deleted.
1592 Note
1593 that a
1594 .Ql \e
1595 (escape) character or an
1596 .Sy LNEXT
1597 character preceding the erase
1598 or kill character removes any special function.
1599 .It
1600 If
1601 .Dv ECHONL
1602 is set, the
1603 .Sy NL
1604 character is echoed even if
1605 .Dv ECHO
1606 is not set.
1607 This is useful for terminals set to local echo (so called
1608 half-duplex).
1609 .El
1610 .Pp
1611 If
1612 .Dv ECHOCTL
1613 and
1614 .Dv IEXTEN
1615 are set, all control characters (characters
1616 with codes between 0 and 37 octal) other than
1617 .Sy ASCII TAB ,
1618 .Sy ASCII NL ,
1619 the
1620 .Sy START
1621 character, and the
1622 .Sy STOP
1623 character,
1624 .Sy ASCII CR ,
1625 and
1626 .Sy ASCII BS
1627 are echoed as
1628 .No ^ Ns Em X ,
1629 where
1630 .Em X
1631 is the character given by adding
1632 .Ql 100
1633 octal to the code of the control character (so
1634 that the character with octal code
1635 .Ql 1
1636 is echoed as
1637 .No ^ Ns Sy A ) ,
1638 and the
1639 .Sy ASCII DEL
1640 character,
1641 with code
1642 .Ql 177
1643 octal, is echoed as
1644 .No ^ Ns Sy \&? .
1645 .Pp
1646 If
1647 .Dv NOFLSH
1648 is set, the normal flush of the input and output queues
1649 associated with the
1650 .Sy INTR ,
1651 .Sy QUIT ,
1652 .Sy STATUS ,
1653 and
1654 .Sy SUSP
1655 characters is not done.
1656 This bit should be set when restarting system calls
1657 that read from or write to a terminal
1658 .Po
1659 see
1660 .Xr sigaction 2
1661 .Pc .
1662 .Pp
1663 If
1664 .Dv TOSTOP
1665 and
1666 .Dv IEXTEN
1667 are set, the signal
1668 .Dv SIGTTOU
1669 is sent to
1670 a process that tries to write to its controlling terminal if it is not in the
1671 foreground process group for that terminal.
1672 This signal normally stops the process.
1673 Otherwise, the output generated by that process is output to the
1674 current output stream.
1675 Processes that are blocking or ignoring
1676 .Dv SIGTTOU
1677 signals are excepted and allowed to produce output, if any.
1678 .Pp
1679 If
1680 .Dv FLUSHO
1681 and
1682 .Dv IEXTEN
1683 are set, data written to the terminal is
1684 discarded.
1685 This bit is set when the
1686 .Sy FLUSH
1687 character is typed.
1688 A program can cancel the effect of typing the
1689 .Sy FLUSH
1690 character by clearing
1691 .Dv FLUSHO .
1692 .Pp
1693 If
1694 .Dv PENDIN
1695 and
1696 .Dv IEXTEN
1697 are set, any input that has not yet been read
1698 is reprinted when the next character arrives as input.
1699 .Dv PENDIN
1700 is then
1701 automatically cleared.
1702 .Pp
1703 If
1704 .Dv IEXTEN
1705 is set, the following implementation-defined functions are
1706 enabled: special characters (
1707 .Sy WERASE ,
1708 .Sy REPRINT ,
1709 .Sy DISCARD ,
1710 and
1711 .Sy LNEXT )
1712 and local flags (
1713 .Dv TOSTOP ,
1714 .Dv ECHOCTL ,
1715 .Dv ECHOPRT ,
1716 .Dv ECHOKE ,
1717 .Dv FLUSHO ,
1718 and
1719 .Dv PENDIN ) .
1720 .Ss "Minimum and Timeout"
1721 The
1722 .Sy MIN
1723 and
1724 .Sy TIME
1725 values were described previously, in the
1726 subsection,
1727 .Sy Non-canonical Mode Input Processing .
1728 The initial value of
1729 .Sy MIN
1730 is 1, and the initial value of
1731 .Sy TIME
1732 is 0.
1733 .Ss "Terminal Size"
1734 The number of lines and columns on the terminal's display is specified in the
1735 .Vt winsize
1736 structure defined by
1737 .In sys/termios.h
1738 and includes the following members:
1739 .Bd -literal -offset 2n
1740 unsigned        short ws_row;  /* rows, in characters */
1741 unsigned short  ws_col;        /* columns, in characters */
1742 unsigned short  ws_xpixel;     /* horizontal size, in pixels */
1743 unsigned short  ws_ypixel;     /* vertical size, in pixels */
1744 .Ed
1745 .Ss "Termio Structure"
1746 The SunOS/SVR4
1747 .Vt termio
1748 structure is used by some
1749 .Fn ioctl Ns s ;
1750 it is defined by
1751 .In sys/termio.h
1752 and includes the following members:
1753 .Bd -literal -offset 2n
1754 unsigned        short   c_iflag;    /* input modes */
1755 unsigned        short   c_oflag;    /* output modes */
1756 unsigned        short   c_cflag;    /* control modes */
1757 unsigned        short   c_lflag;    /* local modes */
1758 char                    c_line;     /* line discipline */
1759 unsigned        char    c_cc[NCC];  /* control chars */
1760 .Ed
1761 .Pp
1762 The special control characters are defined by the array
1763 .Fa c_cc .
1764 The symbolic name
1765 .Dv NCC
1766 is the size of the Control-character array and is also
1767 defined by
1768 .In termio.h .
1769 The relative positions, subscript names, and typical
1770 default values for each function are as follows:
1771 .Bl -column "Relative Positions" "Subscript Names" "Typical Default Values"
1772 .It Relative Positions Ta Subscript Names Ta Typical Default Values
1773 .It 0 Ta VINTR Ta EXT
1774 .It 1 Ta VQUIT Ta FS
1775 .It 2 Ta VERASE Ta DEL
1776 .It 3 Ta VKILL Ta NAK
1777 .It 4 Ta VEOF Ta EOT
1778 .It 5 Ta VEOL Ta NUL
1779 .It 6 Ta VEOL2 Ta NUL
1780 .It 7 Ta Reserved Ta
1781 .El
1782 .Pp
1783 The
1784 .Sy MIN
1785 values is stored in the
1786 .Dv VMIN
1787 element of the
1788 .Fa c_cc
1789 array; the
1790 .Sy TIME
1791 value is stored in the
1792 .Dv VTIME
1793 element of the
1794 .Fa c_cc
1795 array.
1796 The
1797 .Dv VMIN
1798 element is the same element as the
1799 .Dv VEOF
1800 element; the
1801 .Dv VTIME
1802 element is the same element as the
1803 .Dv VEOL
1804 element.
1805 .Pp
1806 The calls that use the
1807 .Va termio
1808 structure only affect the flags and control
1809 characters that can be stored in the
1810 .Vt termio
1811 structure; all other flags and control characters are unaffected.
1812 .Ss "Modem Lines"
1813 On special files representing serial ports, modem control lines can be read.
1814 Control lines (if the underlying hardware supports it) may also be changed.
1815 Status lines are read-only.
1816 The following modem control and status lines may be
1817 supported by a device; they are defined by
1818 .In sys/termios.h :
1819 .Pp
1820 .Bl -tag -width "TIOCM_DTR" -compact -offset 2n
1821 .It Dv TIOCM_LE
1822 line enable
1823 .It Dv TIOCM_DTR








1824 data terminal ready
1825 .It Dv TIOCM_RTS







1826 request to send
1827 .It Dv TIOCM_ST







1828 secondary transmit
1829 .It Dv TIOCM_SR







1830 secondary receive
1831 .It Dv TIOCM_CTS







1832 clear to send
1833 .It Dv TIOCM_CAR







1834 carrier detect
1835 .It Dv TIOCM_RNG







1836 ring
1837 .It Dv TIOCM_DSR







1838 data set ready
1839 .El
1840 .Pp
1841 .Dv TIOCM_CD
1842 is a synonym for
1843 .Dv TIOCM_CAR ,
1844 and
1845 .Dv TIOCM_RI
1846 is a synonym for
1847 .Dv TIOCM_RNG .
1848 Not all of these are necessarily supported by any
1849 particular device; check the manual page for the device in question.
1850 .Pp

1851 The software carrier mode can be enabled or disabled using the
1852 .Dv TIOCSSOFTCAR
1853 .Fn ioctl .
1854 If the software carrier flag for a line is off,
1855 the line pays attention to the hardware carrier detect (DCD) signal.
1856 The
1857 .Sy tty
1858 device associated with the line cannot be opened until
1859 .Sy DCD
1860 is asserted.
1861 If the software carrier flag is on, the line behaves as if
1862 .Sy DCD
1863 is always asserted.
1864 .Pp

1865 The software carrier flag is usually turned on for locally connected terminals
1866 or other devices, and is off for lines with modems.
1867 .Pp
1868 To be able to issue the
1869 .Dv TIOCGSOFTCAR
1870 and
1871 .Dv TIOCSSOFTCAR
1872 .Fn ioctl
1873 calls, the
1874 .Sy tty
1875 line should be opened with
1876 .Dv O_NDELAY
1877 so that the
1878 .Xr open 2
1879 will not wait for the carrier.
1880 .Ss "Default Values"
1881 The initial
1882 .Vt termios
1883 values upon driver open is configurable.
1884 This is accomplished by setting the "ttymodes" property in the file
1885 .Pa /kernel/drv/options.conf .
1886 Since this property is assigned during system
1887 initialization, any change to the "ttymodes" property will not take effect
1888 until the next reboot.
1889 The string value assigned to this property should be in
1890 the same format as the output of the
1891 .Xr stty 1
1892 command with the -g option.
1893 .Pp
1894 If this property is undefined, the following
1895 .Vt termios
1896 modes are in effect.
1897 The initial input control value is
1898 .Dv BRKINT ,
1899 .Dv ICRNL ,
1900 .Dv IXON ,
1901 .Dv IMAXBEL .
1902 The initial output control value is
1903 .Dv OPOST ,
1904 .Dv ONLCR ,
1905 .Dv TAB3 .
1906 The initial hardware control value is
1907 .Dv B9600 ,
1908 .Dv CS8 ,
1909 .Dv CREAD .
1910 The initial line-discipline control value is
1911 .Dv ISIG ,
1912 .Dv ICANON ,
1913 .Dv IEXTEN ,
1914 .Dv ECHO ,
1915 .Dv ECHOK ,
1916 .Dv ECHOE ,
1917 .Dv ECHOKE ,
1918 .Dv ECHOCTL .
1919 .Sh IOCTLS
1920 The
1921 .Fn ioctl Ns s
1922 supported by devices and
1923 .Sy STREAMS
1924 modules providing the
1925 .Xr termios 3C
1926 interface are listed below.
1927 Some calls may not be supported by all devices or modules.
1928 The functionality provided by these calls is also
1929 available through the preferred function call interface specified on
1930 .Nm termios .
1931 .Bl -tag -width TIOCSSOFTCAR
1932 .It Dv TCGETS
1933 The argument is a pointer to a
1934 .Vt termios
1935 structure.
1936 The current terminal parameters are fetched and stored into that structure.
1937 .It Dv TCSETS
1938 The argument is a pointer to a
1939 .Vt termios
1940 structure.
1941 The current terminal parameters are set from the values stored in that structure.
1942 The change is immediate.
1943 .It Dv TCSETSW
1944 The argument is a pointer to a
1945 .Vt termios
1946 structure.
1947 The current terminal parameters are set from the values stored in that structure.
1948 The change occurs after all characters queued for output have been transmitted.
1949 This form should be used when changing parameters that affect output.
1950 .It Dv TCSETSF
1951 The argument is a pointer to a
1952 .Vt termios
1953 structure.
1954 The current terminal parameters are set from the values stored in that structure.
1955 The change occurs after all characters queued for output have been transmitted;
1956 all characters queued for input are discarded and then the change occurs.
1957 .It Dv TCGETA
1958 The argument is a pointer to a
1959 .Vt termio
1960 structure.
1961 The current terminal parameters are fetched, and those parameters that can be
1962 stored in a
1963 .Vt termio
1964 structure are stored into that structure.
1965 .It Dv TCSETA
1966 The argument is a pointer to a
1967 .Vt termio
1968 structure.
1969 Those terminal parameters that can be stored in a
1970 .Vt termio
1971 structure are set from the values stored in that structure.
1972 The change is immediate.
1973 .It Dv TCSETAW
1974 The argument is a pointer to a
1975 .Vt termio
1976 structure.
1977 Those terminal parameters that can be stored in a
1978 .Vt termio
1979 structure are set from
1980 the values stored in that structure.
1981 The change occurs after all characters queued for output have been transmitted.
1982 This form should be used when changing parameters that affect output.
1983 .It Dv TCSETAF
1984 The argument is a pointer to a
1985 .Vt termio
1986 structure.
1987 Those terminal parameters that can be stored in a
1988 .Vt termio
1989 structure are set from the values stored in that structure.
1990 The change occurs after all characters queued





























1991 for output have been transmitted; all characters queued for input are discarded
1992 and then the change occurs.
1993 .It Dv TCSBRK
1994 The argument is an
1995 .Vt int
1996 value.
1997 Wait for the output to drain.
1998 If the argument is
1999 .Sy 0 ,
2000 then send a break (zero valued bits for 0\&.25 seconds).
2001 .It Dv TCXONC
2002 Start/stop control.
2003 The argument is an
2004 .Vt int
2005 value.
2006 If the argument is
2007 .Sy 0 ,
2008 suspend output; if
2009 .Sy 1 ,
2010 restart suspended output; if
2011 .Sy 2 ,
2012 suspend input; if
2013 .Sy 3 ,
2014 restart suspended input.
2015 .It Dv TCFLSH
2016 The argument is an
2017 .Vt int
2018 value.
2019 If the argument is
2020 .Sy 0 ,
2021 flush the input queue; if
2022 .Sy 1 ,
2023 flush the output queue; if
2024 .Sy 2 ,
2025 flush both the input and output queues.
2026 .It Dv TIOCGPGRP
2027 The argument is a pointer to a
2028 .Vt pid_t .
2029 Set the value of that
2030 .Vt pid_t
2031 to the process group
2032 .Sy ID
2033 of the foreground process group associated with the terminal.
2034 See
2035 .Xr termios 3C
2036 for a description of
2037 .Dv TCGETPGRP .
2038 .It Dv TIOCSPGRP
2039 The argument is a pointer to a
2040 .Vt pid_t .
2041 Associate the process group whose
2042 process group
2043 .Sy ID
2044 is specified by the value of that
2045 .Vt pid_t
2046 with the terminal.
2047 The new process group value must be in the range of valid process
2048 group
2049 .Sy ID
2050 values.
2051 Otherwise, the error
2052 .Er EPERM
2053 is returned.
2054 .It Dv TIOCGSID
2055 The argument is a pointer to a
2056 .Vt pid_t .
2057 The session ID of the terminal is fetched and stored in the
2058 .Vt pid_t .
2059 .It Dv TIOCGWINSZ
2060 The argument is a pointer to a
2061 .Vt winsize
2062 structure.
2063 The terminal driver's



2064 notion of the terminal size is stored into that structure.
2065 .It Dv TIOCSWINSZ
2066 The argument is a pointer to a
2067 .Vt winsize
2068 structure.
2069 The terminal driver's




2070 notion of the terminal size is set from the values specified in that structure.
2071 If the new sizes are different from the old sizes, a
2072 .Dv SIGWINCH
2073 signal is set to the process group of the terminal.
2074 .It Dv TIOCMBIS
2075 The argument is a pointer to an
2076 .Vt int
2077 whose value is a mask containing modem control lines to be turned on.
2078 The control lines whose bits are set in




2079 the argument are turned on; no other control lines are affected.
2080 .It Dv TIOCMBIC
2081 The argument is a pointer to an
2082 .Vt int
2083 whose value is a mask containing modem control lines to be turned off.
2084 The control lines whose bits are set in





2085 the argument are turned off; no other control lines are affected.
2086 .It Dv TIOCMGET
2087 The argument is a pointer to an
2088 .Vt int .
2089 The current state of the modem
2090 status lines is fetched and stored in the
2091 .Vt int
2092 pointed to by the argument.
2093 .It Dv TIOCMSET
2094 The argument is a pointer to an
2095 .Vt int
2096 containing a new set of modem control lines.
2097 The modem control lines are turned on or off, depending on









2098 whether the bit for that mode is set or clear.
2099 .It Dv TIOCSPPS
2100 The argument is a pointer to an
2101 .Vt int
2102 that determines whether pulse-per-second event handling is to be enabled
2103 (non-zero) or disabled (zero).





2104 If a one-pulse-per-second reference clock is attached to the serial line's data
2105 carrier detect input, the local system clock will be calibrated to it.
2106 A clock with a high error, that is, a deviation of more than 25 microseconds
2107 per tick, is ignored.
2108 .It Dv TIOCGPPS
2109 The argument is a pointer to an
2110 .Vt int ,
2111 in which the state of the even handling is returned.
2112 The
2113 .Vt int
2114 is set to a non-zero value if pulse-per-second (PPS) handling has been enabled.
2115 Otherwise, it is set to zero.
2116 .It Dv TIOCGSOFTCAR
2117 The argument is a pointer to an
2118 .Vt int
2119 whose value is
2120 .Sy 1
2121 or
2122 .Sy 0 ,





2123 depending on whether the software carrier detect is turned on or off.
2124 .It Dv TIOCSSOFTCAR
2125 The argument is a pointer to an
2126 .Vt int
2127 whose value is
2128 .Sy 1
2129 or
2130 .Sy 0 .
2131 The value of the integer should be
2132 .Sy 0
2133 to turn off software carrier, or
2134 .Sy 1
2135 to turn it on.
2136 .It Dv TIOCGPPSEV
2137 The argument is a pointer to a
2138 .Vt "struct ppsclockev" .
2139 This structure contains the following members:
2140 .Bd -literal -offset 2n







2141 struct timeval tv;
2142 uint32_t serial;
2143 .Ed
2144 .Pp
2145 .Fa tv
2146 is the system clock timestamp when the event (pulse on the
2147 .Sy DCD
2148 pin) occurred.
2149 .Fa serial
2150 is the ordinal of the event, which each consecutive event
2151 being assigned the next ordinal.
2152 The first event registered gets a
2153 .Fa serial
2154 value of
2155 .Sy 1 .
2156 The
2157 .Dv TIOCGPPSEV
2158 returns the last event registered; multiple calls will persistently return the
2159 same event until a new one is registered.
2160 In addition to time stamping and saving the event, if it is of
2161 one-second period and of consistently high accuracy, the local system clock
2162 will automatically calibrate to it.
2163 .El
2164 .Sh FILES
2165 Files in or under
2166 .Pa /dev
2167 .Sh SEE ALSO
2168 .Xr stty 1 ,
2169 .Xr fork 2 ,
2170 .Xr getpgid 2 ,
2171 .Xr getsid 2 ,
2172 .Xr ioctl 2 ,
2173 .Xr setsid 2 ,
2174 .Xr sigaction 2 ,
2175 .Xr signal 3C ,
2176 .Xr tcsetpgrp 3C ,
2177 .Xr termios 3C ,
2178 .Xr signal.h 3HEAD ,
2179 .Xr streamio 7I