Print this page
12315 errors in section 7i of the manual
Split |
Close |
Expand all |
Collapse all |
--- old/usr/src/man/man7i/termio.7i
+++ new/usr/src/man/man7i/termio.7i
1 1 .\" Copyright (c) 2005, Sun Microsystems, Inc. All Rights Reserved.
2 2 .\" Copyright 2019, Joyent, Inc. All Rights Reserved.
3 3 .\" Copyright 1989 AT&T
4 4 .\" The contents of this file are subject to the terms of the
5 5 .\" Common Development and Distribution License (the "License").
6 6 .\" You may not use this file except in compliance with the License.
7 7 .\"
↓ open down ↓ |
7 lines elided |
↑ open up ↑ |
8 8 .\" You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9 9 .\" or http://www.opensolaris.org/os/licensing.
10 10 .\" See the License for the specific language governing permissions
11 11 .\" and limitations under the License.
12 12 .\"
13 13 .\" When distributing Covered Code, include this CDDL HEADER in each
14 14 .\" file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15 15 .\" If applicable, add the following below this CDDL HEADER, with the
16 16 .\" fields enclosed by brackets "[]" replaced with your own identifying
17 17 .\" information: Portions Copyright [yyyy] [name of copyright owner]
18 -.Dd March 17, 2019
18 +.Dd February 17, 2020
19 19 .Dt TERMIO 7I
20 20 .Os
21 21 .Sh NAME
22 22 .Nm termio
23 23 .Nd general terminal interface
24 24 .Sh SYNOPSIS
25 25 .In termio.h
26 26 .Fn ioctl "int fildes" "int request" "struct termio *arg"
27 27 .Fn ioctl "int fildes" "int request" "int arg"
28 28 .Pp
29 29 .In termios.h
30 30 .Fn ioctl "int fildes" "int request" "struct termios *arg"
31 31 .Sh DESCRIPTION
32 32 This release supports a general interface for asynchronous communications ports
33 33 that is hardware-independent.
34 34 The user interface to this functionality is using
35 35 function calls (the preferred interface) described in
36 36 .Xr termios 3C
37 37 or
38 38 .Fn ioctl
39 39 commands described in this section.
40 40 This section also discusses the
41 41 common features of the terminal subsystem which are relevant with both user
42 42 interfaces.
43 43 .Pp
44 44 When a terminal file is opened, it normally causes the process to wait until a
45 45 connection is established.
46 46 In practice, user programs seldom open terminal
47 47 files; they are opened by the system and become a user's standard input,
48 48 output, and error files.
49 49 The first terminal file opened by the session leader
50 50 that is not already associated with a session becomes the controlling terminal
51 51 for that session.
52 52 The controlling terminal plays a special role in handling
53 53 quit and interrupt signals, as discussed below.
54 54 The controlling terminal is
55 55 inherited by a child process during a
56 56 .Xr fork 2 .
57 57 A process can break this
58 58 association by changing its session using
59 59 .Xr setsid 2 .
60 60 .Pp
61 61 A terminal associated with one of these files ordinarily operates in
62 62 full-duplex mode.
63 63 Characters may be typed at any time, even while output is
64 64 occurring, and are only lost when the character input buffers of the system
65 65 become completely full, which is rare.
66 66 For example, the number of characters in
67 67 the line discipline buffer may exceed
68 68 .Brq Dv MAX_CANON
69 69 and
70 70 .Dv IMAXBEL
71 71 (see below) is not set, or the user may accumulate
72 72 .Brq Dv MAX_INPUT
73 73 number of input characters that have not yet been read by some program.
74 74 When the input
75 75 limit is reached, all the characters saved in the buffer up to that point are
76 76 thrown away without notice.
77 77 .Ss "Session Management (Job Control)"
78 78 A control terminal will distinguish one of the process groups in the session
79 79 associated with it to be the foreground process group.
80 80 All other process
81 81 groups in the session are designated as background process groups.
82 82 This foreground process group plays a special role in handling signal-generating
83 83 input characters, as discussed below.
84 84 By default, when a controlling terminal
85 85 is allocated, the controlling process's process group is assigned as
86 86 foreground process group.
87 87 .Pp
88 88 Background process groups in the controlling process's session are subject to a
89 89 job control line discipline when they attempt to access their controlling
90 90 terminal.
91 91 Process groups can be sent signals that will cause them to stop,
92 92 unless they have made other arrangements.
93 93 An exception is made for members of
94 94 orphaned process groups.
95 95 .Pp
96 96 An orphaned process group is one where the process group (see
97 97 .Xr getpgid 2 )
98 98 has no members with a parent in a different process group but sharing the same
99 99 controlling terminal.
100 100 When a member of an orphaned process group attempts to
101 101 access its controlling terminal, EIO is returned because there would be no way
102 102 to restart the process if it were stopped on one of these signals.
103 103 .Pp
104 104 If a member of a background process group attempts to read its controlling
105 105 terminal, its process group will be sent a
106 106 .Dv SIGTTIN
107 107 signal, which will
108 108 normally cause the members of that process group to stop.
109 109 If, however, the
110 110 process is ignoring or holding
111 111 .Dv SIGTTIN ,
112 112 or is a member of an orphaned
113 113 process group, the read will fail with
114 114 .Va errno
115 115 set to
116 116 .Er EIO ,
117 117 and no signal is sent.
118 118 .Pp
119 119 If a member of a background process group attempts to write its controlling
120 120 terminal and the
121 121 .Dv TOSTOP
122 122 bit is set in the
123 123 .Fa c_lflag
124 124 field, its process group is sent a
125 125 .Dv SIGTTOU
126 126 signal, which will normally cause the
127 127 members of that process group to stop.
128 128 If, however, the process is ignoring or
129 129 holding
130 130 .Dv SIGTTOU ,
131 131 the write will succeed.
132 132 If the process is not ignoring
133 133 or holding
134 134 .Dv SIGTTOU
135 135 and is a member of an orphaned process group, the
136 136 write will fail with
137 137 .Va errno
138 138 set to
139 139 .Er EIO ,
140 140 and no signal will be sent.
141 141 .Pp
142 142 If
143 143 .Dv TOSTOP
144 144 is set and a member of a background process group attempts to
145 145 .Fn ioctl
146 146 its controlling terminal, and that
147 147 .Fn ioctl
148 148 will modify terminal parameters (for example,
149 149 .Dv TCSETA ,
150 150 .Dv TCSETAW ,
151 151 .Dv TCSETAF ,
152 152 or
153 153 .Dv TIOCSPGRP ) ,
154 154 its process group will be sent a
155 155 .Dv SIGTTOU
156 156 signal, which will normally cause the members of that process group to stop.
157 157 If, however, the process is ignoring or holding
158 158 .Dv SIGTTOU ,
159 159 the ioctl will succeed.
160 160 If the process is not ignoring or holding
161 161 .Dv SIGTTOU
162 162 and is a member of an orphaned
163 163 process group, the write will fail with
164 164 .Va errno
165 165 set to
166 166 .Er EIO ,
167 167 and no signal will be sent.
168 168 .Ss "Canonical Mode Input Processing"
169 169 Normally, terminal input is processed in units of lines.
170 170 A line is delimited by
171 171 a newline
172 172 .Po
173 173 .Sy ASCII LF
174 174 .Pc
175 175 character, an end-of-file
176 176 .Po
177 177 .Sy ASCII EOT
178 178 .Pc
179 179 character, or an end-of-line character.
180 180 This means that a program attempting to
181 181 read will block until an entire line has been typed.
182 182 Also, no matter how many
183 183 characters are requested in the read call, at most one line will be returned.
184 184 It is not necessary, however, to read a whole line at once; any number of
185 185 characters may be requested in a read, even one, without losing information.
186 186 .Pp
187 187 During input, erase, erase2, and kill processing is normally done.
188 188 The
189 189 .Sy ERASE
190 190 and
191 191 .Sy ERASE2
192 192 character (by default, the character
193 193 .Sy DEL
194 194 for
195 195 .Sy ERASE
196 196 and
197 197 .Sy Control-h
198 198 for
199 199 .Sy ERASE2 )
200 200 erases the last character typed.
201 201 The
202 202 .Sy WERASE
203 203 character (the character
204 204 .Sy Control-w )
205 205 erases the
206 206 last "word" typed in the current input line (but not any preceding spaces or
207 207 tabs).
208 208 A
209 209 .Dq word
210 210 is defined as a sequence of non-blank characters, with tabs counted as blanks.
211 211 None of
212 212 .Sy ERASE
213 213 or
214 214 .Sy ERASE2
215 215 or
216 216 .Sy WERASE
217 217 will erase beyond the beginning of the line.
218 218 The
219 219 .Sy KILL
220 220 character (by default,
221 221 the character
222 222 .Sy NAK )
223 223 kills (deletes) the entire input line, and optionally
224 224 outputs a newline character.
225 225 All these characters operate on a key stroke basis,
↓ open down ↓ |
197 lines elided |
↑ open up ↑ |
226 226 independent of any backspacing or tabbing that may have been done.
227 227 The
228 228 .Sy REPRINT
229 229 character (the character
230 230 .Sy Control-r )
231 231 prints a newline followed by all characters that have not been read.
232 232 Reprinting also occurs automatically if
233 233 characters that would normally be erased from the screen are fouled by program
234 234 output.
235 235 The characters are reprinted as if they were being echoed;
236 -consequencely, if
236 +consequently, if
237 237 .Dv ECHO
238 238 is not set, they are not printed.
239 239 .Pp
240 240 The
241 241 .Sy ERASE ,
242 242 .Sy ERASE2 ,
243 243 and
244 244 .Sy KILL
245 245 characters may be entered literally by preceding them with the escape character.
246 246 In this case, the escape character is not read.
247 247 The erase, erase2, and kill characters may be changed.
248 248 .Ss "Non-canonical Mode Input Processing"
249 249 In non-canonical mode input processing, input characters are not assembled into
250 250 lines, and erase and kill processing does not occur.
251 251 The
252 252 .Sy MIN
253 253 and
254 254 .Sy TIME
255 255 values are used to determine how to process the characters received.
256 256 .Pp
257 257 .Sy MIN
258 258 represents the minimum number of characters that should be received
259 259 when the read is satisfied (that is, when the characters are returned to the
260 260 user).
261 261 .Sy TIME
262 262 is a timer of 0\&.10-second granularity that is used to timeout
263 263 bursty and short-term data transmissions.
264 264 The four possible values for
265 265 .Sy MIN
266 266 and
267 267 .Sy TIME
268 268 and their interactions are described below.
269 269 .Bl -tag -width "Case A: Min > 0, Time > 0"
270 270 .It Sy Case A: MIN > 0, TIME > 0
271 271 In this case,
272 272 .Sy TIME
273 273 serves as an intercharacter timer and is activated
274 274 after the first character is received.
275 275 Since it is an intercharacter timer, it
276 276 is reset after a character is received.
277 277 The interaction between
278 278 .Sy MIN
279 279 and
280 280 .Sy TIME
281 281 is as follows: as soon as one character is received, the
282 282 intercharacter timer is started.
283 283 If
284 284 .Sy MIN
285 285 characters are received before
286 286 the intercharacter timer expires (note that the timer is reset upon receipt of
287 287 each character), the read is satisfied.
288 288 If the timer expires before
289 289 .Sy MIN
290 290 characters are received, the characters received to that point are returned to
291 291 the user.
292 292 Note that if
293 293 .Sy TIME
294 294 expires, at least one character will be
295 295 returned because the timer would not have been enabled unless a character was
296 296 received.
297 297 In this case (MIN > 0, TIME > 0), the read sleeps until the
298 298 .Sy MIN
299 299 and
300 300 .Sy TIME
301 301 mechanisms are activated by the receipt of the first character.
302 302 If the number of characters read is less than the number of characters
303 303 available, the timer is not reactivated and the subsequent read is satisfied
304 304 immediately.
305 305 .It Sy Case B: MIN > 0, TIME = 0
306 306 In this case, since the value of
307 307 .Sy TIME
308 308 is zero, the timer plays no role
309 309 and only
310 310 .Sy MIN
311 311 is significant.
312 312 A pending read is not satisfied until
313 313 .Sy MIN
314 314 characters are received (the pending read sleeps until
315 315 .Sy MIN
316 316 characters are received).
317 317 A program that uses this case to read record based
318 318 terminal
319 319 .Sy I/O
320 320 may block indefinitely in the read operation.
321 321 .It Sy Case C: MIN = 0, TIME > 0
322 322 In this case, since
323 323 .Sy MIN
324 324 0,
325 325 .Sy TIME
326 326 no longer represents an
327 327 intercharacter timer: it now serves as a read timer that is activated as soon
328 328 as a
329 329 .Xr read 2
330 330 is done.
331 331 A read is satisfied as soon as a single character is
332 332 received or the read timer expires.
333 333 Note that, in this case, if the timer
334 334 expires, no character is returned.
335 335 If the timer does not expire, the only way
336 336 the read can be satisfied is if a character is received.
337 337 In this case, the
338 338 read will not block indefinitely waiting for a character; if no character is
339 339 received within
340 340 .Sy TIME
341 341 *\&.10 seconds after the read is initiated, the read
342 342 returns with zero characters.
343 343 .It Sy Case D: MIN = 0, TIME = 0
344 344 In this case, return is immediate.
345 345 The minimum of either the number of
346 346 characters requested or the number of characters currently available is
347 347 returned without waiting for more characters to be input.
348 348 .El
349 349 .Ss "Comparing Different Cases of MIN, TIME Interaction"
350 350 Some points to note about
351 351 .Sy MIN
352 352 and
353 353 .Sy TIME :
354 354 .Bl -bullet -offset 2n
355 355 .It
356 356 In the following explanations, note that the interactions of
357 357 .Sy MIN
358 358 and
359 359 .Sy TIME
360 360 are not symmetric.
361 361 For example, when
362 362 .Sy MIN
363 363 > 0 and
364 364 .Sy TIME
365 365 = 0,
366 366 .Sy TIME
367 367 has no effect.
368 368 However, in the opposite case, where
369 369 .Sy MIN
370 370 = 0 and
371 371 .Sy TIME
372 372 > 0, both
373 373 .Sy MIN
374 374 and
375 375 .Sy TIME
376 376 play a role in that
377 377 .Sy MIN
378 378 is satisfied with the receipt of a single character.
379 379 .It
380 380 Also note that in case A
381 381 .Po
382 382 .Sy MIN
383 383 > 0,
384 384 .Sy TIME
385 385 > 0
386 386 .Pc ,
387 387 .Sy TIME
388 388 represents
389 389 an intercharacter timer, whereas in case C
390 390 .Po
391 391 .Sy MIN
392 392 = 0,
393 393 .Sy TIME
394 394 > 0
395 395 .Pc ,
396 396 .Sy TIME
397 397 represents a read timer.
398 398 .El
399 399 .Pp
↓ open down ↓ |
153 lines elided |
↑ open up ↑ |
400 400 These two points highlight the dual purpose of the
401 401 .Sy MIN/TIME
402 402 feature.
403 403 Cases A and B, where
404 404 .Sy MIN
405 405 > 0, exist to handle burst mode activity (for
406 406 example, file transfer programs), where a program would like to process at
407 407 least
408 408 .Sy MIN
409 409 characters at a time.
410 -In case A, the inteercharacter timer is
410 +In case A, the intercharacter timer is
411 411 activated by a user as a safety measure; in case B, the timer is turned off.
412 412 .Pp
413 413 Cases C and D exist to handle single character, timed transfers.
414 414 These cases
415 415 are readily adaptable to screen-based applications that need to know if a
416 416 character is present in the input queue before refreshing the screen.
417 417 In case
418 418 C, the read is timed, whereas in case D, it is not.
419 419 .Pp
420 420 Another important note is that
421 421 .Sy MIN
↓ open down ↓ |
1 lines elided |
↑ open up ↑ |
422 422 is always just a minimum.
423 423 It does not
424 424 denote a record length.
425 425 For example, if a program does a read of 20 bytes,
426 426 .Sy MIN
427 427 is 10, and 25 characters are present, then 20 characters will be
428 428 returned to the user.
429 429 .Ss "Writing Characters"
430 430 When one or more characters are written, they are transmitted to the terminal
431 431 as soon as previously written characters have finished typing.
432 -nputt characters
432 +Input characters
433 433 are echoed as they are typed if echoing has been enabled.
434 434 If a process produces
435 435 characters more rapidly than they can be typed, it will be suspended when its
436 436 output queue exceeds some limit.
437 437 When the queue is drained down to some
438 438 threshold, the program is resumed.
439 439 .Ss "Special Characters"
440 440 Certain characters have special functions on input.
441 441 These functions and their default character values are summarized as follows:
442 442 .Bl -tag -width REPRINT
443 443 .It Sy INTR
444 444 (Control-c or
445 445 .Sy ASCII ETX )
446 446 generates a
447 447 .Dv SIGINT
448 448 signal.
449 449 .Dv SIGINT
450 450 is sent to all foreground processes associated with the controlling terminal.
451 451 Normally, each such process is forced to terminate, but arrangements may be
452 452 made either to ignore the signal or to receive a trap to an agreed upon
453 453 location.
454 454 (See
455 455 .Xr signal.h 3HEAD ) .
456 456 .It Sy QUIT
457 457 (Control-| or
458 458 .Sy ASCII FS )
459 459 generates a
460 460 .Dv SIGQUIT
461 461 signal.
462 462 Its treatment
463 463 is identical to the interrupt signal except that, unless a receiving process
464 464 has made other arrangements, it will not only be terminated but a core image
465 465 file (called
466 466 .Pa core )
467 467 will be created in the current working directory.
468 468 .It Sy ERASE
469 469 (DEL) erases the preceding character.
470 470 It does not erase beyond
471 471 the start of a line, as delimited by a
472 472 .Sy NL ,
473 473 .Sy EOF ,
474 474 .Sy EOL ,
475 475 or
476 476 .Sy EOL2
477 477 character.
478 478 .It Sy ERASE2
479 479 (Control-h or
480 480 .Sy ASCII BS )
481 481 erases the preceding character, with behaviour identical to that of ERASE.
482 482 .It Sy WERASE
483 483 (Control-w or
484 484 .Sy ASCII ETX )
485 485 erases the preceding
486 486 .Dq word .
487 487 It does not erase beyond the start of a line, as delimited by a
488 488 .Sy NL ,
489 489 .Sy EOF ,
490 490 .Sy EOL ,
491 491 or
492 492 .Sy EOL2
493 493 character.
494 494 .It Sy KILL
495 495 (Control-u or
496 496 .Sy ASCII NAK )
497 497 deletes the entire line, as delimited by a
498 498 .Sy NL ,
499 499 .Sy EOF ,
500 500 .Sy EOL ,
501 501 or
502 502 .Sy EOL2
503 503 character.
504 504 .It Sy REPRINT
505 505 (Control-r or
506 506 .Sy ASCII DC2 )
507 507 reprints all characters, preceded by a newline, that have not been read.
508 508 .It Sy EOF
509 509 (Control-d or
510 510 .Sy ASCII EOT )
511 511 may be used to generate an end-of-file from a terminal.
512 512 When received, all the characters waiting to be read are immediately
513 513 passed to the program, without waiting for a newline, and the
514 514 .Sy EOF
515 515 is discarded.
516 516 Thus, if no characters are waiting (that is, the
517 517 .Sy EOF
518 518 occurred
519 519 at the beginning of a line) zero characters are passed back, which is the
520 520 standard end-of-file indication.
521 521 Unless escaped, the
522 522 .Sy EOF
523 523 character is not
524 524 echoed.
525 525 Because
526 526 .Sy EOT
527 527 is the default
528 528 .Sy EOF
529 529 character, this prevents
530 530 terminals that respond to
531 531 .Sy EOT
532 532 from hanging up.
533 533 .It Sy NL
534 534 .Pq Sy ASCII LF
535 535 is the normal line delimiter.
536 536 It cannot be changed or escaped.
537 537 .It Sy EOL
538 538 .Pq Sy ASCII NULL
539 539 is an additional line delimiter, like
540 540 .Sy NL .
541 541 It is not normally used.
542 542 .It Sy EOL2
543 543 is another additional line delimiter.
544 544 .It Sy SWTCH
545 545 (Control-z or
546 546 .Sy ASCII EM )
547 547 Header file symbols related to this special
548 548 character are present for compatibility purposes only and the kernel takes no
549 549 special action on matching SWTCH (except to discard the character).
550 550 .It Sy SUSP
551 551 (Control-z or
552 552 .Sy ASCII SUB )
553 553 generates a
554 554 .Dv SIGTSTP
555 555 signal.
556 556 .Dv SIGTSTP
557 557 stops all processes in the foreground process group for that terminal.
558 558 .It Sy DSUSP
559 559 (Control-y or
560 560 .Sy ASCII EM ) .
561 561 It generates a
562 562 .Dv SIGTSTP
563 563 signal as
564 564 .Sy SUSP
565 565 does, but the signal is sent when a process in the foreground
566 566 process group attempts to read the
567 567 .Sy DSUSP
568 568 character, rather than when it is typed.
569 569 .It Sy STOP
570 570 (Control-s or
571 571 .Sy ASCII DC3 )
572 572 can be used to suspend output temporarily.
573 573 It is useful with
574 574 .Sy CRT
575 575 terminals to prevent output from disappearing before it can be read.
576 576 While output is suspended,
577 577 .Sy STOP
578 578 characters are ignored and
579 579 not read.
580 580 .It Sy START
581 581 (Control-q or
582 582 .Sy ASCII DC1 )
583 583 is used to resume output.
584 584 Output has been suspended by a
585 585 .Sy STOP
586 586 character.
587 587 While output is not suspended,
588 588 .Sy START
589 589 characters are ignored and not read.
590 590 .It Sy DISCARD
591 591 (Control-o or
592 592 .Sy ASCII SI )
593 593 causes subsequent output to be discarded.
594 594 Output is discarded until another
595 595 .Sy DISCARD
596 596 character is typed, more input
597 597 arrives, or the condition is cleared by a program.
598 598 .It Sy STATUS
599 599 (Control-t or
600 600 .Sy ASCII DC4 )
601 601 generates a
602 602 .Dv SIGINFO
603 603 signal.
604 604 Processes with a handler will output status information when they receive
605 605 .Dv SIGINFO ,
606 606 for
607 607 example,
608 608 .Xr dd 1M .
609 609 If a process does not have a
610 610 .Dv SIGINFO
611 611 handler, the
612 612 signal will be ignored.
613 613 .It Sy LNEXT
614 614 (Control-v or
615 615 .Sy ASCII SYN )
616 616 causes the special meaning of the next character to be ignored.
617 617 This works for all the special characters mentioned above.
618 618 It
619 619 allows characters to be input that would otherwise be interpreted by the system
620 620 (for example
621 621 .Sy KILL ,
622 622 .Sy QUIT ) .
623 623 The character values for
624 624 .Sy INTR ,
625 625 .Sy QUIT ,
626 626 .Sy ERASE ,
627 627 .Sy ERASE2 ,
628 628 .Sy WERASE ,
629 629 .Sy KILL ,
630 630 .Sy REPRINT ,
631 631 .Sy EOF ,
632 632 .Sy EOL ,
633 633 .Sy EOL2 ,
634 634 .Sy SWTCH ,
635 635 .Sy SUSP ,
636 636 .Sy DSUSP ,
637 637 .Sy STOP ,
638 638 .Sy START ,
639 639 .Sy DISCARD ,
640 640 .Sy STATUS ,
641 641 and
642 642 .Sy LNEXT
643 643 may be changed to suit individual tastes.
644 644 If the value of a special control character
645 645 is
646 646 .Dv _POSIX_VDISABLE
647 647 (0), the function of that special control character is disabled.
648 648 The
649 649 .Sy ERASE ,
650 650 .Sy ERASE2 ,
651 651 .Sy KILL ,
652 652 and
653 653 .Sy EOF
654 654 characters may be
655 655 escaped by a preceding backslash (\e) character, in which case no special
656 656 function is done.
657 657 Any of the special characters may be preceded by the
658 658 .Sy LNEXT
659 659 character, in
660 660 which case no special function is done.
661 661 .El
662 662 .Ss "Modem Disconnect"
663 663 When a modem disconnect is detected, a
664 664 .Dv SIGHUP
665 665 signal is sent to the
666 666 terminal's controlling process.
667 667 Unless other arrangements have been made, these
668 668 signals cause the process to terminate.
669 669 If
670 670 .Dv SIGHUP
671 671 is ignored or caught,
672 672 any subsequent read returns with an end-of-file indication until the terminal
673 673 is closed.
674 674 .Pp
675 675 If the controlling process is not in the foreground process group of the
676 676 terminal, a
677 677 .Dv SIGTSTP
678 678 is sent to the terminal's foreground process group.
679 679 Unless other arrangements have been made, these signals cause the processes to
680 680 stop.
681 681 .Pp
682 682 Processes in background process groups that attempt to access the controlling
↓ open down ↓ |
240 lines elided |
↑ open up ↑ |
683 683 terminal after modem disconnect while the terminal is still allocated to the
684 684 session will receive appropriate
685 685 .Dv SIGTTOU
686 686 and
687 687 .Dv SIGTTIN
688 688 signals.
689 689 Unless other arrangements have been made, this signal causes the processes to
690 690 stop.
691 691 .Pp
692 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
693 +with a successful open by the controlling process, or deallocated by the
694 694 controlling process.
695 695 .Ss "Terminal Parameters"
696 696 The parameters that control the behavior of devices and modules providing the
697 697 .Vt termios
698 698 interface are specified by the
699 699 .Vt termios
700 700 structure defined by
701 701 .In termios.h .
702 702 Several
703 703 .Xr ioctl 2
704 704 system calls that fetch or change
705 705 these parameters use this structure that contains the following members:
706 706 .Bd -literal -offset 2n
707 707 tcflag_t c_iflag; /* input modes */
708 708 tcflag_t c_oflag; /* output modes */
709 709 tcflag_t c_cflag; /* control modes */
710 710 tcflag_t c_lflag; /* local modes */
711 711 cc_t c_cc[NCCS]; /* control chars */
712 712 .Ed
713 713 .Pp
714 714 The special control characters are defined by the array
715 715 .Fa c_cc .
716 716 The symbolic name
717 717 .Dv NCCS
718 718 is the size of the Control-character array and is also
719 719 defined by
720 720 .In termios.h .
721 721 The relative positions, subscript names, and
722 722 typical default values for each function are as follows:
723 723 .Bl -column "Relative Position" "Subscript Name" "Typical Default Value"
724 724 .It Relative Position Ta Subscript Name Ta Typical Default Value
725 725 .It 0 Ta Dv VINTR Ta Sy ETX
726 726 .It 1 Ta Dv VQUIT Ta Sy FS
727 727 .It 2 Ta Dv VERASE Ta Sy DEL
728 728 .It 3 Ta Dv VKILL Ta Sy NAK
729 729 .It 4 Ta Dv VEOF Ta Sy EOT
730 730 .It 5 Ta Dv VEOL Ta Sy NUL
731 731 .It 6 Ta Dv VEOL2 Ta Sy NUL
732 732 .It 7 Ta Dv VWSTCH Ta Sy NUL
733 733 .It 8 Ta Dv VSTART Ta Sy NUL
734 734 .It 9 Ta Dv VSTOP Ta Sy DC3
735 735 .It 10 Ta Dv VSUSP Ta Sy SUB
736 736 .It 11 Ta Dv VDSUSP Ta Sy EM
737 737 .It 12 Ta Dv VREPRINT Ta Sy DC2
738 738 .It 13 Ta Dv VDISCARD Ta Sy SI
739 739 .It 14 Ta Dv VWERASE Ta Sy ETB
740 740 .It 15 Ta Dv VLNEXT Ta Sy SYN
741 741 .It 16 Ta Dv VSTATUS Ta Sy DC4
742 742 .It 17 Ta Dv VERASE2 Ta Sy BS
743 743 .It 18-19 Ta Reserved Ta
744 744 .El
745 745 .Ss "Input Modes"
746 746 The
747 747 .Fa c_iflag
748 748 field describes the basic terminal input control:
749 749 .Pp
750 750 .Bl -tag -width "IMAXBEL" -offset 2n -compact
751 751 .It Dv IGNBRK
752 752 Ignore break condition.
753 753 .It Dv BRKINT
754 754 Signal interrupt on break.
755 755 .It Dv IGNPAR
756 756 Ignore characters with parity errors.
757 757 .It Dv PARMRK
758 758 Mark parity errors.
759 759 .It Dv INPCK
760 760 Enable input parity check.
761 761 .It Dv ISTRIP
762 762 Strip character.
763 763 .It Dv INLCR
764 764 Map NL to CR on input.
765 765 .It Dv IGNCR
766 766 Ignore CR.
767 767 .It Dv ICRNL
768 768 Map CR to NL on input.
769 769 .It Dv IUCLC
770 770 Map upper-case to lower-case on input.
771 771 .It Dv IXON
772 772 Enable start/stop output control.
773 773 .It Dv IXANY
774 774 Enable any character to restart output.
775 775 .It Dv IXOFF
776 776 Enable start/stop input control.
777 777 .It Dv IMAXBEL
778 778 Echo
779 779 .Sy BEL
780 780 on input line too long.
781 781 .El
782 782 .Pp
783 783 If
784 784 .Dv IGNBRK
785 785 is set, a break condition (a character framing error with data
786 786 all zeros) detected on input is ignored, that is, not put on the input queue
787 787 and therefore not read by any process.
788 788 If
789 789 .Dv IGNBRK
790 790 is not set and
791 791 .Dv BRKINT
792 792 is set, the break condition shall flush the input and output
793 793 queues and if the terminal is the controlling terminal of a foreground process
794 794 group, the break condition generates a single
795 795 .Dv SIGINT
796 796 signal to that
797 797 foreground process group.
798 798 If neither
799 799 .Dv IGNBRK
800 800 nor
801 801 .Dv BRKINT
802 802 is set, a
803 803 break condition is read as a single
804 804 .Ql \e0
805 805 .Pq Sy ASCII NULL
806 806 character, or if
807 807 .Dv PARMRK
808 808 is set, as
809 809 .Ql \e377 ,
810 810 .Ql \e0 ,
811 811 .Em c ,
812 812 where
813 813 .Ql \e377
814 814 is a single character
815 815 with value 377 octal (0xff hex, 255 decimal),
816 816 .Ql \e0
817 817 is a single character with value
818 818 .Sy 0 ,
819 819 and
820 820 .Em c
821 821 is the errored character received.
822 822 .Pp
823 823 If
824 824 .Dv IGNPAR
825 825 is set, a byte with framing or parity errors (other than
826 826 break) is ignored.
827 827 .Pp
828 828 If
829 829 .Dv PARMRK
830 830 is set, and
831 831 .Dv IGNPAR
832 832 is not set, a byte with a framing or
833 833 parity error (other than break) is given to the application as the
834 834 three-character sequence:
835 835 .Ql \e377 ,
836 836 .Ql \e0 ,
837 837 c, where
838 838 .Ql \e377
839 839 is a single character with value 377 octal (0xff hex, 255 decimal),
840 840 .Ql \e0
841 841 is a single character with value 0, and c is the errored character received.
842 842 To avoid ambiguity in this case, if
843 843 .Dv ISTRIP
844 844 is not set, a valid character
845 845 of
846 846 .Ql \e377
847 847 is given to the application as
848 848 .Ql \e377 .
849 849 If neither
850 850 .Dv IGNPAR
851 851 nor
852 852 .Dv PARMRK
853 853 is set, a framing or parity error (other than break) is given to
854 854 the application as a single
855 855 .Ql \e0
856 856 .Po
857 857 .Sy ASCII NULL
858 858 .Pc
859 859 character.
860 860 .Pp
861 861 If
862 862 .Dv INPCK
863 863 is set, input parity checking is enabled.
864 864 If
865 865 .Dv INPCK
866 866 is not
867 867 set, input parity checking is disabled.
868 868 This allows output parity generation
869 869 without input parity errors.
870 870 Note that whether input parity checking is
871 871 enabled or disabled is independent of whether parity detection is enabled or
872 872 disabled.
873 873 If parity detection is enabled but input parity checking is
874 874 disabled, the hardware to which the terminal is connected will recognize the
875 875 parity bit, but the terminal special file will not check whether this is set
876 876 correctly or not.
877 877 .Pp
878 878 If
879 879 .Dv ISTRIP
880 880 is set, valid input characters are first stripped to seven
881 881 bits, otherwise all eight bits are processed.
882 882 .Pp
883 883 If
884 884 .Dv INLCR
885 885 is set, a received
886 886 .Sy NL
887 887 character is translated into a
888 888 .Sy CR
889 889 character.
890 890 If
891 891 .Dv IGNCR
892 892 is set, a received
893 893 .Sy CR
894 894 character is ignored (not read).
895 895 Otherwise, if
896 896 .Dv ICRNL
897 897 is set, a received
898 898 .Sy CR
899 899 character is translated into a
900 900 .Sy NL
901 901 character.
902 902 .Pp
903 903 If
904 904 .Dv IUCLC
905 905 is set, a received upper case, alphabetic character is
906 906 translated into the corresponding lower case character.
907 907 .Pp
908 908 If
909 909 .Dv IXON
910 910 is set, start/stop output control is enabled.
911 911 A received
912 912 .Sy STOP
913 913 character suspends output and a received
914 914 .Sy START
915 915 character
916 916 restarts output.
917 917 The
918 918 .Sy STOP
919 919 and
920 920 .Sy START
921 921 characters will not be read,
922 922 but will merely perform flow control functions.
923 923 If
924 924 .Dv IXANY
925 925 is set, any
926 926 input character restarts output that has been suspended.
927 927 .Pp
928 928 If
929 929 .Dv IXOFF
930 930 is set, the system transmits a
931 931 .Sy STOP
932 932 character when the
933 933 input queue is nearly full, and a
934 934 .Sy START
935 935 character when enough input has
936 936 been read so that the input queue is nearly empty again.
937 937 .Pp
938 938 If
939 939 .Dv IMAXBEL
940 940 is set, the
941 941 .Sy ASCII BEL
942 942 character is echoed if the input stream overflows.
943 943 Further input is not stored, but any input already present in
944 944 the input stream is not disturbed.
945 945 If
946 946 .Dv IMAXBEL
947 947 is not set, no
948 948 .Sy BEL
949 949 character is echoed, and all input present in the input queue is discarded if
950 950 the input stream overflows.
951 951 .Ss "Output Modes"
952 952 The
953 953 .Fa c_oflag
954 954 field specifies the system treatment of output:
955 955 .Pp
956 956 .Bl -tag -width ONLRET -offset 2n -compact
957 957 .It Dv OPOST
958 958 Post-process output.
959 959 .It Dv OLCUC
960 960 Map lower case to upper on output.
961 961 .It Dv ONLCR
962 962 Map NL to CR-NL on output.
963 963 .It Dv OCRNL
964 964 Map CR to NL on output.
965 965 .It Dv ONOCR
966 966 No
967 967 .Sy CR
968 968 output at column 0.
969 969 .It Dv ONLRET
970 970 .Sy NL
971 971 performs
972 972 .Sy CR
973 973 function.
974 974 .It Dv OFILL
975 975 Use fill characters for delay.
976 976 .It Dv OFDEL
977 977 Fill is
978 978 .Sy DEL ,
979 979 else
980 980 .Sy INULL .
981 981 .It Dv NLDLY
982 982 Select newline delays:
983 983 .Bl -tag -width NL0 -compact -offset 2n
984 984 .It Sy NL0
985 985 .It Sy NL1
986 986 .El
987 987 .It Dv CRDLY
988 988 Select carriage-return delays:
989 989 .Bl -tag -width CR0 -compact -offset 2n
990 990 .It Dv CR0
991 991 .It Dv CR1
992 992 .It Dv CR2
993 993 .It Dv CR3
994 994 .El
995 995 .It Dv TABDLY
996 996 Select horizontal tab delays or tab expansion:
997 997 .Bl -tag -width XTABS -compact -offset 2n
998 998 .It Dv TAB0
999 999 .It Dv TAB1
1000 1000 .It Dv TAB2
1001 1001 .It Dv TAB3
1002 1002 Expand tabs to spaces
1003 1003 .It Dv XTABS
1004 1004 Expand tabs to spaces
1005 1005 .El
1006 1006 .It Dv BSDLY
1007 1007 Select backspace delays:
1008 1008 .Bl -tag -width BS0 -offset 2n -compact
1009 1009 .It Dv BS0
1010 1010 .It Dv BS1
1011 1011 .El
1012 1012 .It Dv VTDLY
1013 1013 Select vertical tab delays:
1014 1014 .Bl -tag -width VT0 -offset 2n -compact
1015 1015 .It Dv VT0
1016 1016 .It Dv VT1
1017 1017 .El
1018 1018 .It Dv FFDLY
1019 1019 Select form feed delays:
1020 1020 .Bl -tag -width FF0 -offset 2n -compact
1021 1021 .It Dv FF0
1022 1022 .It Dv FF1
1023 1023 .El
1024 1024 .El
1025 1025 .Pp
1026 1026 If
1027 1027 .Dv OPOST
1028 1028 is set, output characters are post-processed as indicated by the
1029 1029 remaining flags; otherwise, characters are transmitted without change.
1030 1030 .Pp
1031 1031 If
1032 1032 .Dv OLCUC
1033 1033 is set, a lower case alphabetic character is transmitted as the
1034 1034 corresponding upper case character.
1035 1035 This function is often used in conjunction
1036 1036 with
1037 1037 .Dv IUCLC .
1038 1038 .Pp
1039 1039 If
1040 1040 .Dv ONLCR
1041 1041 is set, the
1042 1042 .Sy NL
1043 1043 character is transmitted as the
1044 1044 .Sy CR-NL
1045 1045 character pair.
1046 1046 If
1047 1047 .Dv OCRNL
1048 1048 is set, the
1049 1049 .Sy CR
1050 1050 character is transmitted as the
1051 1051 .Sy NL
1052 1052 character.
1053 1053 If
1054 1054 .Dv ONOCR
1055 1055 is set, no
1056 1056 .Sy CR
1057 1057 character is transmitted when at column 0 (first position).
1058 1058 If
1059 1059 .Dv ONRET
1060 1060 is set, the
1061 1061 .Sy NL
1062 1062 character is assumed to do the carriage-return function; the column
1063 1063 pointer is set to 0 and the delays specified for
1064 1064 .Sy CR
1065 1065 are used.
1066 1066 Otherwise, the
1067 1067 .Sy NL
1068 1068 character is assumed to do just the line-feed function; the column
1069 1069 pointer remains unchanged.
1070 1070 The column pointer is also set to 0 if the
1071 1071 .Sy CR
1072 1072 character is actually transmitted.
1073 1073 .Pp
1074 1074 The delay bits specify how long transmission stops to allow for mechanical or
1075 1075 other movement when certain characters are sent to the terminal.
1076 1076 In all cases, a value of 0 indicates no delay.
1077 1077 If
1078 1078 .Dv OFILL
1079 1079 is set, fill characters are transmitted for delay instead of a timed delay.
1080 1080 This is useful for high baud rate terminals that need only a minimal delay.
1081 1081 If
1082 1082 .Dv OFDEL
1083 1083 is set, the
1084 1084 fill character is
1085 1085 .Sy DEL ;
1086 1086 otherwise it is
1087 1087 .Sy NULL .
1088 1088 .Pp
1089 1089 If a form-feed or vertical-tab delay is specified, it lasts for about 2
1090 1090 seconds.
1091 1091 .Pp
1092 1092 Newline delay lasts about 0\&.10 seconds.
1093 1093 If
1094 1094 .Dv ONLRET
1095 1095 is set, the carriage-return delays are used instead of the newline delays.
1096 1096 If
1097 1097 .Dv OFILL
1098 1098 is set, two fill characters are transmitted.
1099 1099 .Pp
1100 1100 Carriage-return delay type 1 is dependent on the current column position, type
1101 1101 2 is about 0\&.10 seconds, and type 3 is about 0\&.15 seconds.
1102 1102 If
1103 1103 .Dv OFILL
1104 1104 is set, delay type 1 transmits two fill characters, and type 2 transmits four
1105 1105 fill characters.
1106 1106 .Pp
1107 1107 Horizontal-tab delay type 1 is dependent on the current column position.
1108 1108 Type 2 is about 0\&.10 seconds.
1109 1109 Type 3 specifies that tabs are to be expanded into spaces.
1110 1110 If
1111 1111 .Dv OFILL
1112 1112 is set, two fill characters are transmitted for any delay.
1113 1113 .Pp
1114 1114 Backspace delay lasts about 0\&.05 seconds.
1115 1115 If
1116 1116 .Dv OFILL
1117 1117 is set, one fill character is transmitted.
1118 1118 .Pp
1119 1119 The actual delays depend on line speed and system load.
1120 1120 .Ss "Control Modes"
1121 1121 The
1122 1122 .Fa c_cflag
1123 1123 field describes the hardware control of the terminal:
1124 1124 .Bl -tag -width CIBAUDEXT -offset 2n
1125 1125 .It Dv CBAUD
1126 1126 Baud rate:
1127 1127 .Bl -tag -width B460800 -compact
1128 1128 .It Dv B0
1129 1129 Hang up
1130 1130 .It Dv B50
1131 1131 50 baud
1132 1132 .It Dv B75
1133 1133 75 baud
1134 1134 .It Dv B110
1135 1135 110 baud
1136 1136 .It Dv B134
1137 1137 134 baud
1138 1138 .It Dv B150
1139 1139 150 baud
1140 1140 .It Dv B200
1141 1141 200 baud
1142 1142 .It Dv B300
1143 1143 300 baud
1144 1144 .It Dv B600
1145 1145 600 baud
1146 1146 .It Dv B1200
1147 1147 1200 baud
1148 1148 .It Dv B1800
1149 1149 1800 baud
1150 1150 .It Dv B2400
1151 1151 2400 baud
1152 1152 .It Dv B4800
1153 1153 4800 baud
1154 1154 .It Dv B9600
1155 1155 9600 baud
1156 1156 .It Dv B19200
1157 1157 19200 baud
1158 1158 .It Dv EXTA
1159 1159 External A
1160 1160 .It Dv B38400
1161 1161 38400 baud
1162 1162 .It Dv EXTB
1163 1163 External B
1164 1164 .It Dv B57600
1165 1165 57600 baud
1166 1166 .It Dv B76800
1167 1167 76800 baud
1168 1168 .It Dv B115200
1169 1169 115200 baud
1170 1170 .It Dv B153600
1171 1171 153600 baud
1172 1172 .It Dv B230400
1173 1173 230400 baud
1174 1174 .It Dv B307200
1175 1175 307200 baud
1176 1176 .It Dv B460800
1177 1177 460800 baud
1178 1178 .El
1179 1179 .It Dv CSIZE
1180 1180 Character size:
1181 1181 .Bl -tag -width CIBAUDEXT -compact
1182 1182 .It Dv CS5
1183 1183 5 bits
1184 1184 .It Dv CS6
1185 1185 6 bits
1186 1186 .It Dv CS7
1187 1187 7 bits
1188 1188 .It Dv CS8
1189 1189 8 bits
1190 1190 .It Dv CSTOPB
1191 1191 Send two stop bits, else one
1192 1192 .It Dv CREAD
1193 1193 Enable receiver
1194 1194 .It Dv PARENB
1195 1195 Parity enable
1196 1196 .It Dv PARODD
1197 1197 Odd parity, else even
1198 1198 .It Dv HUPCL
1199 1199 Hang up on last close
1200 1200 .It Dv CLOCAL
1201 1201 Local line, else dial-up
1202 1202 .It Dv CIBAUD
1203 1203 Input baud rate, if different from output rate
1204 1204 .It Dv PAREXT
1205 1205 Extended parity for mark and space parity
1206 1206 .It Dv CRTSXOFF
1207 1207 Enable inbound hardware flow control
1208 1208 .It Dv CRTSCTS
1209 1209 Enable outbound hardware flow control
1210 1210 .It Dv CBAUDEXT
1211 1211 Bit to indicate output speed > B38400
1212 1212 .It Dv CIBAUDEXT
1213 1213 Bit to indicate input speed > B38400
1214 1214 .El
1215 1215 .El
1216 1216 .Pp
1217 1217 The
1218 1218 .Dv CBAUD
1219 1219 bits together with the
1220 1220 .Dv CBAUDEXT
1221 1221 bit specify the output baud rate.
1222 1222 To retrieve the output speed from the
1223 1223 .Vt termios
1224 1224 structure pointed to by
1225 1225 .Fa termios_p
1226 1226 see the following code segment.
1227 1227 .Bd -literal -offset 2n
1228 1228 speed_t ospeed;
1229 1229 if (termios_p->c_cflag & CBAUDEXT)
1230 1230 ospeed = (termios_p->c_cflag & CBAUD) + CBAUD + 1;
1231 1231 else
1232 1232 ospeed = termios_p->c_cflag & CBAUD;
1233 1233 .Ed
1234 1234 .Pp
1235 1235 To store the output speed in the termios structure pointed to by
1236 1236 .Fa termios_p
1237 1237 see the following code segment.
1238 1238 .Bd -literal -offset 2n
1239 1239 speed_t ospeed;
1240 1240 if (ospeed > CBAUD) {
1241 1241 termios_p->c_cflag |= CBAUDEXT;
1242 1242 ospeed -= (CBAUD + 1);
1243 1243 } else {
1244 1244 termios_p->c_cflag &= ~CBAUDEXT;
1245 1245 }
1246 1246 termios_p->c_cflag =
1247 1247 (termios_p->c_cflag & ~CBAUD) | (ospeed & CBAUD);
1248 1248 .Ed
1249 1249 .Pp
1250 1250 The zero baud rate,
1251 1251 .Dv B0 ,
1252 1252 is used to hang up the connection.
1253 1253 If
1254 1254 .Dv B0
1255 1255 is specified, the data-terminal-ready signal is not asserted.
1256 1256 Normally, this disconnects the line.
1257 1257 .Pp
1258 1258 If the
1259 1259 .Dv CIBAUDEXT
1260 1260 or
1261 1261 .Dv CIBAUD
1262 1262 bits are not zero, they specify the input baud rate, with the
1263 1263 .Dv CBAUDEXT
1264 1264 and
1265 1265 .Dv CBAUD
1266 1266 bits specifying the output baud rate; otherwise, the output and input baud
1267 1267 rates are both specified by the
1268 1268 .Dv CBAUDEXT
1269 1269 and
1270 1270 .Dv CBAUD
1271 1271 bits.
1272 1272 The values for the
1273 1273 .Dv CIBAUD
1274 1274 bits are the same as the values for the
1275 1275 .Dv CBAUD
1276 1276 bits, shifted left
1277 1277 .Dv IBSHIFT
1278 1278 bits.
1279 1279 For any particular hardware, impossible speed changes are
1280 1280 ignored.
1281 1281 To retrieve the input speed in the
1282 1282 .Vt termios
1283 1283 structure pointed to
1284 1284 by
1285 1285 .Fa termios_p
1286 1286 see the following code segment.
1287 1287 .Bd -literal -offset 2n
1288 1288 speed_t ispeed;
1289 1289 if (termios_p->c_cflag & CIBAUDEXT) {
1290 1290 ispeed = ((termios_p->c_cflag & CIBAUD) >> IBSHIFT)
1291 1291 + (CIBAUD >> IBSHIFT) + 1;
1292 1292 } else {
1293 1293 ispeed = (termios_p->c_cflag & CIBAUD) >> IBSHIFT;
1294 1294 }
1295 1295 .Ed
1296 1296 .Pp
1297 1297 To store the input speed in the
1298 1298 .Vt termios
1299 1299 structure pointed to by
1300 1300 .Fa termios_p
1301 1301 see the following code segment.
1302 1302 .Bd -literal -offset 2n
1303 1303 speed_t ispeed;
1304 1304 if (ispeed == 0) {
1305 1305 ispeed = termios_p->c_cflag & CBAUD;
1306 1306 if (termios_p->c_cflag & CBAUDEXT)
1307 1307 ispeed += (CBAUD + 1);
1308 1308 }
1309 1309 if ((ispeed << IBSHIFT) > CIBAUD) {
1310 1310 termios_p->c_cflag |= CIBAUDEXT;
1311 1311 ispeed -= ((CIBAUD >> IBSHIFT) + 1);
1312 1312 } else {
1313 1313 termios_p->c_cflag &= ~CIBAUDEXT;
1314 1314 }
1315 1315 termios_p->c_cflag =
1316 1316 (termios_p->c_cflag & ~CIBAUD) | ((ispeed << IBSHIFT) & CIBAUD);
1317 1317 .Ed
1318 1318 .Pp
1319 1319 The
1320 1320 .Dv CSIZE
1321 1321 bits specify the character size in bits for both transmission and reception.
1322 1322 This size does not include the parity bit, if any.
1323 1323 If
1324 1324 .Dv CSTOPB
1325 1325 is set, two stop bits are used; otherwise, one stop bit is used.
1326 1326 For example, at 110 baud, two stops bits are required.
1327 1327 .Pp
1328 1328 If
1329 1329 .Dv PARENB
1330 1330 is set, parity generation and detection is enabled, and a
1331 1331 parity bit is added to each character.
1332 1332 If parity is enabled, the
1333 1333 .Dv PARODD
1334 1334 flag specifies odd parity if set; otherwise, even parity is used.
1335 1335 .Pp
1336 1336 If
1337 1337 .Dv CREAD
1338 1338 is set, the receiver is enabled.
1339 1339 Otherwise, no characters are received.
1340 1340 .Pp
1341 1341 If
1342 1342 .Dv HUPCL
1343 1343 is set, the line is disconnected when the last process with the
1344 1344 line open closes it or terminates.
1345 1345 That is, the data-terminal-ready signal is not asserted.
1346 1346 .Pp
1347 1347 If
1348 1348 .Dv CLOCAL
1349 1349 is set, the line is assumed to be a local, direct connection
1350 1350 with no modem control; otherwise, modem control is assumed.
1351 1351 .Pp
1352 1352 If
1353 1353 .Dv CRTSXOFF
1354 1354 is set, inbound hardware flow control is enabled.
1355 1355 .Pp
1356 1356 If
1357 1357 .Dv CRTSCTS
1358 1358 is set, outbound hardware flow control is enabled.
1359 1359 .Pp
1360 1360 The four possible combinations for the state of
1361 1361 .Dv CRTSCTS
1362 1362 and
1363 1363 .Dv CRTSXOFF
1364 1364 bits and their interactions are described below.
1365 1365 .Bl -tag -width "Case C:"
1366 1366 .It Sy Case A :
1367 1367 .Dv CRTSCTS
1368 1368 off,
1369 1369 .Dv CRTSXOFF
1370 1370 off.
1371 1371 In this case the hardware flow control is disabled.
1372 1372 .It Sy Case B :
1373 1373 .Dv CRTSCTS
1374 1374 on,
1375 1375 .Dv CRTSXOFF
1376 1376 off.
1377 1377 In this case only outbound hardware flow control is enabled.
1378 1378 The state of CTS signal is used to do outbound flow control.
1379 1379 It is expected that output will be suspended if CTS is low and resumed
1380 1380 when CTS is high.
1381 1381 .It Sy Case C :
1382 1382 .Dv CRTSCTS
1383 1383 off,
1384 1384 .Dv CRTSXOFF
1385 1385 on.
1386 1386 In this case only inbound hardware flow control is enabled.
1387 1387 The state of RTS signal is used to do inbound flow control.
1388 1388 It is expected that input will be suspended if RTS is low and resumed when RTS
1389 1389 is high.
1390 1390 .It Sy Case D :
1391 1391 .Dv CRTSCTS
1392 1392 on,
1393 1393 .Dv CRTSXOFF
1394 1394 on.
1395 1395 In this case both inbound and outbound hardware flow control are enabled.
1396 1396 Uses the state of CTS signal to do outbound
1397 1397 flow control and RTS signal to do inbound flow control.
1398 1398 .El
1399 1399 .Ss "Local Modes"
1400 1400 The
1401 1401 .Fa c_lflag
1402 1402 field of the argument structure is used by the line
1403 1403 discipline to control terminal functions.
1404 1404 The basic line discipline provides the following:
1405 1405 .Pp
1406 1406 .Bl -tag -offset 2n -width SIGTTOU -compact
1407 1407 .It Dv ISIG
1408 1408 Enable signals.
1409 1409 .It Dv ICANON
1410 1410 Canonical input (erase and kill processing).
1411 1411 .It Dv XCASE
1412 1412 Canonical upper/lower presentation.
1413 1413 .It Dv ECHO
1414 1414 Enable echo.
1415 1415 .It Dv ECHOE
1416 1416 Echo erase character as
1417 1417 .Sy BS Ns - Ns Sy SP Ns - Ns Sy BS
1418 1418 &.
1419 1419 .It Dv ECHOK
1420 1420 Echo
1421 1421 .Sy NL
1422 1422 after kill character.
1423 1423 .It Dv ECHONL
1424 1424 Echo
1425 1425 .Sy NL .
1426 1426 .It Dv NOFLSH
1427 1427 Disable flush after interrupt or quit.
1428 1428 .It Dv TOSTOP
1429 1429 Send
1430 1430 .It Dv SIGTTOU
1431 1431 for background output.
1432 1432 .It Dv ECHOCTL
1433 1433 Echo control characters as
1434 1434 .Em char ,
1435 1435 delete as ^?.
1436 1436 .It Dv ECHOPRT
1437 1437 Echo erase character as character erased.
1438 1438 .It Dv ECHOKE
1439 1439 .Sy BS Ns - Ns Sy SP Ns - Ns Sy BS
1440 1440 erase entire line on line kill.
1441 1441 .It Dv FLUSHO
1442 1442 Output is being flushed.
1443 1443 .It Dv PENDIN
1444 1444 Retype pending input at next read or input character.
1445 1445 .It Dv IEXTEN
1446 1446 Enable extended (implementation-defined) functions.
1447 1447 .El
1448 1448 .Pp
1449 1449 If
1450 1450 .Dv ISIG
1451 1451 is set, each input character is checked against the special
1452 1452 control characters
1453 1453 .Sy INTR ,
1454 1454 .Sy QUIT ,
1455 1455 .Sy SWTCH ,
1456 1456 .Sy SUSP ,
1457 1457 .Sy STATUS ,
1458 1458 and
1459 1459 .Sy DSUSP .
1460 1460 If an input character matches one of these control characters, the function
1461 1461 associated with that character is performed.
1462 1462 .Po
1463 1463 Note: If
1464 1464 .Sy SWTCH
1465 1465 is set and the character matches, the character is simply discarded.
1466 1466 No other action is taken.
1467 1467 .Pc
1468 1468 If
1469 1469 .Dv ISIG
1470 1470 is not set, no checking is done.
1471 1471 Thus, these special
1472 1472 input functions are possible only if
1473 1473 .Dv ISIG
1474 1474 is set.
1475 1475 .Pp
1476 1476 If
1477 1477 .Dv ICANON
1478 1478 is set, canonical processing is enabled.
1479 1479 This enables the erase
1480 1480 and kill edit functions, and the assembly of input characters into lines
1481 1481 delimited by
1482 1482 .Sy NL-c ,
1483 1483 .Sy EOF ,
1484 1484 .Sy EOL ,
1485 1485 and
1486 1486 .Sy EOL .
1487 1487 If
1488 1488 .Dv ICANON
1489 1489 is not set, read requests are satisfied directly from the input queue.
1490 1490 A read is not satisfied until at least
1491 1491 .Sy MIN
1492 1492 characters have been received or the timeout value
1493 1493 .Sy TIME
1494 1494 has expired between characters.
1495 1495 This allows fast bursts of input to be read efficiently while still allowing
1496 1496 single character input.
1497 1497 The time value represents tenths of seconds.
1498 1498 .Pp
1499 1499 If
1500 1500 .Dv XCASE
1501 1501 is set and
1502 1502 .Dv ICANON
1503 1503 is set, an upper case letter is
1504 1504 accepted on input if preceded by a backslash
1505 1505 .Ql \e
1506 1506 character, and is output preceded by a backslash
1507 1507 .Ql \e
1508 1508 character.
1509 1509 In this mode, the
1510 1510 following escape sequences are generated on output and accepted on input:
1511 1511 .Bl -column "FOR:" "USE:" -offset 2n
1512 1512 .It FOR: Ta USE:
1513 1513 .It ` Ta \e'
1514 1514 .It | Ta \e!
1515 1515 .It \(ap Ta \e^
1516 1516 .It { Ta \e(
1517 1517 .It } Ta \e)
1518 1518 .It \e Ta \e\e
1519 1519 .El
1520 1520 .Pp
1521 1521 For example, input A as \ea, \en as \e\en, and \eN as \e\e\en.
1522 1522 .Pp
1523 1523 If
1524 1524 .Dv ECHO
1525 1525 is set, characters are echoed as received.
1526 1526 .Pp
1527 1527 When
1528 1528 .Dv ICANON
1529 1529 is set, the following echo functions are possible.
1530 1530 .Bl -bullet -offset indent
1531 1531 .It
1532 1532 If
1533 1533 .Dv ECHO
1534 1534 and
1535 1535 .Dv ECHOE
1536 1536 are set, and
1537 1537 .Dv ECHOPRT
1538 1538 is not set, the
1539 1539 .Sy ERASE ,
1540 1540 .Sy ERASE2 ,
1541 1541 and
1542 1542 .Sy WERASE
1543 1543 characters are echoed as one or
1544 1544 more ASCII BS SP BS, which clears the last character(s) from a
1545 1545 .Sy CRT
1546 1546 screen.
1547 1547 .It
1548 1548 If
1549 1549 .Dv ECHO ,
1550 1550 .Dv ECHOPRT ,
1551 1551 and
1552 1552 .Dv IEXTEN
1553 1553 are set, the first
1554 1554 .Sy ERASE ,
1555 1555 .Sy ERASE2 ,
1556 1556 and
1557 1557 .Sy WERASE
1558 1558 character in a sequence echoes as a backslash
1559 1559 .Ql \e ,
1560 1560 followed by the characters being erased.
1561 1561 Subsequent
1562 1562 .Sy ERASE
1563 1563 and
1564 1564 .Sy WERASE
1565 1565 characters echo the characters being erased, in reverse order.
1566 1566 The
1567 1567 next non-erase character causes a
1568 1568 .Ql /
1569 1569 (slash) to be typed before it is echoed.
1570 1570 .Dv ECHOPRT
1571 1571 should be used for hard copy terminals.
1572 1572 .It
1573 1573 If
1574 1574 .Dv ECHOKE
1575 1575 and
1576 1576 .Dv IEXTEN
1577 1577 are set, the kill character is echoed by
1578 1578 erasing each character on the line from the screen (using the mechanism
1579 1579 selected by
1580 1580 .Dv ECHOE
1581 1581 and
1582 1582 .Dv ECHOPR ) .
1583 1583 .It
1584 1584 If
1585 1585 .Dv ECHOK
1586 1586 is set, and
1587 1587 .Dv ECHOKE
1588 1588 is not set, the
1589 1589 .Sy NL
1590 1590 character is
1591 1591 echoed after the kill character to emphasize that the line is deleted.
1592 1592 Note
1593 1593 that a
1594 1594 .Ql \e
1595 1595 (escape) character or an
1596 1596 .Sy LNEXT
1597 1597 character preceding the erase
1598 1598 or kill character removes any special function.
1599 1599 .It
1600 1600 If
1601 1601 .Dv ECHONL
1602 1602 is set, the
1603 1603 .Sy NL
1604 1604 character is echoed even if
1605 1605 .Dv ECHO
1606 1606 is not set.
1607 1607 This is useful for terminals set to local echo (so called
1608 1608 half-duplex).
1609 1609 .El
1610 1610 .Pp
1611 1611 If
1612 1612 .Dv ECHOCTL
1613 1613 and
1614 1614 .Dv IEXTEN
1615 1615 are set, all control characters (characters
1616 1616 with codes between 0 and 37 octal) other than
1617 1617 .Sy ASCII TAB ,
1618 1618 .Sy ASCII NL ,
1619 1619 the
1620 1620 .Sy START
1621 1621 character, and the
1622 1622 .Sy STOP
1623 1623 character,
1624 1624 .Sy ASCII CR ,
1625 1625 and
1626 1626 .Sy ASCII BS
1627 1627 are echoed as
1628 1628 .No ^ Ns Em X ,
1629 1629 where
1630 1630 .Em X
1631 1631 is the character given by adding
1632 1632 .Ql 100
1633 1633 octal to the code of the control character (so
1634 1634 that the character with octal code
1635 1635 .Ql 1
1636 1636 is echoed as
1637 1637 .No ^ Ns Sy A ) ,
1638 1638 and the
1639 1639 .Sy ASCII DEL
1640 1640 character,
1641 1641 with code
1642 1642 .Ql 177
1643 1643 octal, is echoed as
1644 1644 .No ^ Ns Sy \&? .
1645 1645 .Pp
1646 1646 If
1647 1647 .Dv NOFLSH
1648 1648 is set, the normal flush of the input and output queues
1649 1649 associated with the
1650 1650 .Sy INTR ,
1651 1651 .Sy QUIT ,
1652 1652 .Sy STATUS ,
1653 1653 and
1654 1654 .Sy SUSP
1655 1655 characters is not done.
1656 1656 This bit should be set when restarting system calls
1657 1657 that read from or write to a terminal
1658 1658 .Po
1659 1659 see
1660 1660 .Xr sigaction 2
1661 1661 .Pc .
1662 1662 .Pp
1663 1663 If
1664 1664 .Dv TOSTOP
1665 1665 and
1666 1666 .Dv IEXTEN
1667 1667 are set, the signal
1668 1668 .Dv SIGTTOU
1669 1669 is sent to
1670 1670 a process that tries to write to its controlling terminal if it is not in the
1671 1671 foreground process group for that terminal.
1672 1672 This signal normally stops the process.
1673 1673 Otherwise, the output generated by that process is output to the
1674 1674 current output stream.
1675 1675 Processes that are blocking or ignoring
1676 1676 .Dv SIGTTOU
1677 1677 signals are excepted and allowed to produce output, if any.
1678 1678 .Pp
1679 1679 If
1680 1680 .Dv FLUSHO
1681 1681 and
1682 1682 .Dv IEXTEN
1683 1683 are set, data written to the terminal is
1684 1684 discarded.
1685 1685 This bit is set when the
1686 1686 .Sy FLUSH
1687 1687 character is typed.
1688 1688 A program can cancel the effect of typing the
1689 1689 .Sy FLUSH
1690 1690 character by clearing
1691 1691 .Dv FLUSHO .
1692 1692 .Pp
1693 1693 If
1694 1694 .Dv PENDIN
1695 1695 and
1696 1696 .Dv IEXTEN
1697 1697 are set, any input that has not yet been read
1698 1698 is reprinted when the next character arrives as input.
1699 1699 .Dv PENDIN
1700 1700 is then
1701 1701 automatically cleared.
1702 1702 .Pp
1703 1703 If
1704 1704 .Dv IEXTEN
1705 1705 is set, the following implementation-defined functions are
1706 1706 enabled: special characters (
1707 1707 .Sy WERASE ,
1708 1708 .Sy REPRINT ,
1709 1709 .Sy DISCARD ,
1710 1710 and
1711 1711 .Sy LNEXT )
1712 1712 and local flags (
1713 1713 .Dv TOSTOP ,
1714 1714 .Dv ECHOCTL ,
1715 1715 .Dv ECHOPRT ,
1716 1716 .Dv ECHOKE ,
1717 1717 .Dv FLUSHO ,
1718 1718 and
1719 1719 .Dv PENDIN ) .
1720 1720 .Ss "Minimum and Timeout"
1721 1721 The
1722 1722 .Sy MIN
1723 1723 and
1724 1724 .Sy TIME
1725 1725 values were described previously, in the
1726 1726 subsection,
1727 1727 .Sy Non-canonical Mode Input Processing .
1728 1728 The initial value of
1729 1729 .Sy MIN
↓ open down ↓ |
1026 lines elided |
↑ open up ↑ |
1730 1730 is 1, and the initial value of
1731 1731 .Sy TIME
1732 1732 is 0.
1733 1733 .Ss "Terminal Size"
1734 1734 The number of lines and columns on the terminal's display is specified in the
1735 1735 .Vt winsize
1736 1736 structure defined by
1737 1737 .In sys/termios.h
1738 1738 and includes the following members:
1739 1739 .Bd -literal -offset 2n
1740 -unsigned short ws_row; /* rows, in characters */
1740 +unsigned short ws_row; /* rows, in characters */
1741 1741 unsigned short ws_col; /* columns, in characters */
1742 1742 unsigned short ws_xpixel; /* horizontal size, in pixels */
1743 1743 unsigned short ws_ypixel; /* vertical size, in pixels */
1744 1744 .Ed
1745 1745 .Ss "Termio Structure"
1746 1746 The SunOS/SVR4
1747 1747 .Vt termio
1748 1748 structure is used by some
1749 1749 .Fn ioctl Ns s ;
1750 1750 it is defined by
1751 1751 .In sys/termio.h
1752 1752 and includes the following members:
1753 1753 .Bd -literal -offset 2n
1754 1754 unsigned short c_iflag; /* input modes */
1755 1755 unsigned short c_oflag; /* output modes */
1756 1756 unsigned short c_cflag; /* control modes */
1757 1757 unsigned short c_lflag; /* local modes */
1758 1758 char c_line; /* line discipline */
1759 1759 unsigned char c_cc[NCC]; /* control chars */
1760 1760 .Ed
1761 1761 .Pp
1762 1762 The special control characters are defined by the array
1763 1763 .Fa c_cc .
1764 1764 The symbolic name
1765 1765 .Dv NCC
1766 1766 is the size of the Control-character array and is also
1767 1767 defined by
1768 1768 .In termio.h .
1769 1769 The relative positions, subscript names, and typical
1770 1770 default values for each function are as follows:
1771 1771 .Bl -column "Relative Positions" "Subscript Names" "Typical Default Values"
1772 1772 .It Relative Positions Ta Subscript Names Ta Typical Default Values
1773 1773 .It 0 Ta VINTR Ta EXT
1774 1774 .It 1 Ta VQUIT Ta FS
1775 1775 .It 2 Ta VERASE Ta DEL
1776 1776 .It 3 Ta VKILL Ta NAK
1777 1777 .It 4 Ta VEOF Ta EOT
1778 1778 .It 5 Ta VEOL Ta NUL
1779 1779 .It 6 Ta VEOL2 Ta NUL
1780 1780 .It 7 Ta Reserved Ta
1781 1781 .El
1782 1782 .Pp
1783 1783 The
1784 1784 .Sy MIN
1785 1785 values is stored in the
1786 1786 .Dv VMIN
1787 1787 element of the
1788 1788 .Fa c_cc
1789 1789 array; the
1790 1790 .Sy TIME
1791 1791 value is stored in the
1792 1792 .Dv VTIME
1793 1793 element of the
1794 1794 .Fa c_cc
1795 1795 array.
1796 1796 The
1797 1797 .Dv VMIN
1798 1798 element is the same element as the
1799 1799 .Dv VEOF
1800 1800 element; the
1801 1801 .Dv VTIME
1802 1802 element is the same element as the
1803 1803 .Dv VEOL
1804 1804 element.
1805 1805 .Pp
1806 1806 The calls that use the
1807 1807 .Va termio
1808 1808 structure only affect the flags and control
1809 1809 characters that can be stored in the
1810 1810 .Vt termio
1811 1811 structure; all other flags and control characters are unaffected.
1812 1812 .Ss "Modem Lines"
1813 1813 On special files representing serial ports, modem control lines can be read.
1814 1814 Control lines (if the underlying hardware supports it) may also be changed.
1815 1815 Status lines are read-only.
1816 1816 The following modem control and status lines may be
1817 1817 supported by a device; they are defined by
1818 1818 .In sys/termios.h :
1819 1819 .Pp
1820 1820 .Bl -tag -width "TIOCM_DTR" -compact -offset 2n
1821 1821 .It Dv TIOCM_LE
1822 1822 line enable
1823 1823 .It Dv TIOCM_DTR
1824 1824 data terminal ready
1825 1825 .It Dv TIOCM_RTS
1826 1826 request to send
1827 1827 .It Dv TIOCM_ST
1828 1828 secondary transmit
1829 1829 .It Dv TIOCM_SR
1830 1830 secondary receive
1831 1831 .It Dv TIOCM_CTS
1832 1832 clear to send
1833 1833 .It Dv TIOCM_CAR
1834 1834 carrier detect
1835 1835 .It Dv TIOCM_RNG
1836 1836 ring
1837 1837 .It Dv TIOCM_DSR
1838 1838 data set ready
1839 1839 .El
1840 1840 .Pp
1841 1841 .Dv TIOCM_CD
1842 1842 is a synonym for
1843 1843 .Dv TIOCM_CAR ,
1844 1844 and
1845 1845 .Dv TIOCM_RI
1846 1846 is a synonym for
1847 1847 .Dv TIOCM_RNG .
1848 1848 Not all of these are necessarily supported by any
1849 1849 particular device; check the manual page for the device in question.
1850 1850 .Pp
1851 1851 The software carrier mode can be enabled or disabled using the
1852 1852 .Dv TIOCSSOFTCAR
1853 1853 .Fn ioctl .
1854 1854 If the software carrier flag for a line is off,
1855 1855 the line pays attention to the hardware carrier detect (DCD) signal.
1856 1856 The
1857 1857 .Sy tty
1858 1858 device associated with the line cannot be opened until
1859 1859 .Sy DCD
1860 1860 is asserted.
1861 1861 If the software carrier flag is on, the line behaves as if
1862 1862 .Sy DCD
1863 1863 is always asserted.
1864 1864 .Pp
1865 1865 The software carrier flag is usually turned on for locally connected terminals
1866 1866 or other devices, and is off for lines with modems.
1867 1867 .Pp
1868 1868 To be able to issue the
1869 1869 .Dv TIOCGSOFTCAR
1870 1870 and
1871 1871 .Dv TIOCSSOFTCAR
1872 1872 .Fn ioctl
1873 1873 calls, the
1874 1874 .Sy tty
1875 1875 line should be opened with
1876 1876 .Dv O_NDELAY
1877 1877 so that the
1878 1878 .Xr open 2
1879 1879 will not wait for the carrier.
1880 1880 .Ss "Default Values"
1881 1881 The initial
1882 1882 .Vt termios
1883 1883 values upon driver open is configurable.
1884 1884 This is accomplished by setting the "ttymodes" property in the file
1885 1885 .Pa /kernel/drv/options.conf .
1886 1886 Since this property is assigned during system
1887 1887 initialization, any change to the "ttymodes" property will not take effect
1888 1888 until the next reboot.
1889 1889 The string value assigned to this property should be in
1890 1890 the same format as the output of the
1891 1891 .Xr stty 1
1892 1892 command with the -g option.
1893 1893 .Pp
1894 1894 If this property is undefined, the following
1895 1895 .Vt termios
1896 1896 modes are in effect.
1897 1897 The initial input control value is
1898 1898 .Dv BRKINT ,
1899 1899 .Dv ICRNL ,
1900 1900 .Dv IXON ,
1901 1901 .Dv IMAXBEL .
1902 1902 The initial output control value is
1903 1903 .Dv OPOST ,
1904 1904 .Dv ONLCR ,
1905 1905 .Dv TAB3 .
1906 1906 The initial hardware control value is
1907 1907 .Dv B9600 ,
1908 1908 .Dv CS8 ,
1909 1909 .Dv CREAD .
1910 1910 The initial line-discipline control value is
1911 1911 .Dv ISIG ,
1912 1912 .Dv ICANON ,
1913 1913 .Dv IEXTEN ,
1914 1914 .Dv ECHO ,
1915 1915 .Dv ECHOK ,
1916 1916 .Dv ECHOE ,
1917 1917 .Dv ECHOKE ,
1918 1918 .Dv ECHOCTL .
1919 1919 .Sh IOCTLS
1920 1920 The
1921 1921 .Fn ioctl Ns s
1922 1922 supported by devices and
1923 1923 .Sy STREAMS
1924 1924 modules providing the
1925 1925 .Xr termios 3C
1926 1926 interface are listed below.
1927 1927 Some calls may not be supported by all devices or modules.
1928 1928 The functionality provided by these calls is also
1929 1929 available through the preferred function call interface specified on
1930 1930 .Nm termios .
1931 1931 .Bl -tag -width TIOCSSOFTCAR
1932 1932 .It Dv TCGETS
1933 1933 The argument is a pointer to a
1934 1934 .Vt termios
1935 1935 structure.
1936 1936 The current terminal parameters are fetched and stored into that structure.
1937 1937 .It Dv TCSETS
1938 1938 The argument is a pointer to a
1939 1939 .Vt termios
1940 1940 structure.
1941 1941 The current terminal parameters are set from the values stored in that structure.
1942 1942 The change is immediate.
1943 1943 .It Dv TCSETSW
1944 1944 The argument is a pointer to a
1945 1945 .Vt termios
1946 1946 structure.
1947 1947 The current terminal parameters are set from the values stored in that structure.
1948 1948 The change occurs after all characters queued for output have been transmitted.
1949 1949 This form should be used when changing parameters that affect output.
1950 1950 .It Dv TCSETSF
1951 1951 The argument is a pointer to a
1952 1952 .Vt termios
1953 1953 structure.
1954 1954 The current terminal parameters are set from the values stored in that structure.
1955 1955 The change occurs after all characters queued for output have been transmitted;
1956 1956 all characters queued for input are discarded and then the change occurs.
1957 1957 .It Dv TCGETA
1958 1958 The argument is a pointer to a
1959 1959 .Vt termio
1960 1960 structure.
1961 1961 The current terminal parameters are fetched, and those parameters that can be
1962 1962 stored in a
1963 1963 .Vt termio
1964 1964 structure are stored into that structure.
1965 1965 .It Dv TCSETA
1966 1966 The argument is a pointer to a
1967 1967 .Vt termio
1968 1968 structure.
1969 1969 Those terminal parameters that can be stored in a
1970 1970 .Vt termio
1971 1971 structure are set from the values stored in that structure.
1972 1972 The change is immediate.
1973 1973 .It Dv TCSETAW
1974 1974 The argument is a pointer to a
1975 1975 .Vt termio
1976 1976 structure.
1977 1977 Those terminal parameters that can be stored in a
1978 1978 .Vt termio
1979 1979 structure are set from
1980 1980 the values stored in that structure.
1981 1981 The change occurs after all characters queued for output have been transmitted.
1982 1982 This form should be used when changing parameters that affect output.
1983 1983 .It Dv TCSETAF
1984 1984 The argument is a pointer to a
1985 1985 .Vt termio
1986 1986 structure.
1987 1987 Those terminal parameters that can be stored in a
1988 1988 .Vt termio
1989 1989 structure are set from the values stored in that structure.
1990 1990 The change occurs after all characters queued
1991 1991 for output have been transmitted; all characters queued for input are discarded
1992 1992 and then the change occurs.
1993 1993 .It Dv TCSBRK
1994 1994 The argument is an
1995 1995 .Vt int
1996 1996 value.
1997 1997 Wait for the output to drain.
1998 1998 If the argument is
1999 1999 .Sy 0 ,
2000 2000 then send a break (zero valued bits for 0\&.25 seconds).
2001 2001 .It Dv TCXONC
2002 2002 Start/stop control.
2003 2003 The argument is an
2004 2004 .Vt int
2005 2005 value.
2006 2006 If the argument is
2007 2007 .Sy 0 ,
2008 2008 suspend output; if
2009 2009 .Sy 1 ,
2010 2010 restart suspended output; if
2011 2011 .Sy 2 ,
2012 2012 suspend input; if
2013 2013 .Sy 3 ,
2014 2014 restart suspended input.
2015 2015 .It Dv TCFLSH
2016 2016 The argument is an
2017 2017 .Vt int
2018 2018 value.
2019 2019 If the argument is
2020 2020 .Sy 0 ,
2021 2021 flush the input queue; if
2022 2022 .Sy 1 ,
2023 2023 flush the output queue; if
2024 2024 .Sy 2 ,
2025 2025 flush both the input and output queues.
2026 2026 .It Dv TIOCGPGRP
2027 2027 The argument is a pointer to a
2028 2028 .Vt pid_t .
2029 2029 Set the value of that
2030 2030 .Vt pid_t
2031 2031 to the process group
2032 2032 .Sy ID
2033 2033 of the foreground process group associated with the terminal.
2034 2034 See
2035 2035 .Xr termios 3C
2036 2036 for a description of
2037 2037 .Dv TCGETPGRP .
2038 2038 .It Dv TIOCSPGRP
2039 2039 The argument is a pointer to a
2040 2040 .Vt pid_t .
2041 2041 Associate the process group whose
2042 2042 process group
2043 2043 .Sy ID
2044 2044 is specified by the value of that
2045 2045 .Vt pid_t
2046 2046 with the terminal.
2047 2047 The new process group value must be in the range of valid process
2048 2048 group
2049 2049 .Sy ID
2050 2050 values.
2051 2051 Otherwise, the error
2052 2052 .Er EPERM
2053 2053 is returned.
2054 2054 .It Dv TIOCGSID
2055 2055 The argument is a pointer to a
2056 2056 .Vt pid_t .
2057 2057 The session ID of the terminal is fetched and stored in the
2058 2058 .Vt pid_t .
2059 2059 .It Dv TIOCGWINSZ
2060 2060 The argument is a pointer to a
2061 2061 .Vt winsize
2062 2062 structure.
2063 2063 The terminal driver's
2064 2064 notion of the terminal size is stored into that structure.
2065 2065 .It Dv TIOCSWINSZ
2066 2066 The argument is a pointer to a
2067 2067 .Vt winsize
2068 2068 structure.
2069 2069 The terminal driver's
2070 2070 notion of the terminal size is set from the values specified in that structure.
2071 2071 If the new sizes are different from the old sizes, a
2072 2072 .Dv SIGWINCH
2073 2073 signal is set to the process group of the terminal.
2074 2074 .It Dv TIOCMBIS
2075 2075 The argument is a pointer to an
2076 2076 .Vt int
2077 2077 whose value is a mask containing modem control lines to be turned on.
2078 2078 The control lines whose bits are set in
2079 2079 the argument are turned on; no other control lines are affected.
2080 2080 .It Dv TIOCMBIC
2081 2081 The argument is a pointer to an
2082 2082 .Vt int
2083 2083 whose value is a mask containing modem control lines to be turned off.
2084 2084 The control lines whose bits are set in
2085 2085 the argument are turned off; no other control lines are affected.
2086 2086 .It Dv TIOCMGET
2087 2087 The argument is a pointer to an
2088 2088 .Vt int .
2089 2089 The current state of the modem
2090 2090 status lines is fetched and stored in the
2091 2091 .Vt int
2092 2092 pointed to by the argument.
2093 2093 .It Dv TIOCMSET
2094 2094 The argument is a pointer to an
2095 2095 .Vt int
2096 2096 containing a new set of modem control lines.
2097 2097 The modem control lines are turned on or off, depending on
2098 2098 whether the bit for that mode is set or clear.
2099 2099 .It Dv TIOCSPPS
2100 2100 The argument is a pointer to an
2101 2101 .Vt int
2102 2102 that determines whether pulse-per-second event handling is to be enabled
2103 2103 (non-zero) or disabled (zero).
2104 2104 If a one-pulse-per-second reference clock is attached to the serial line's data
2105 2105 carrier detect input, the local system clock will be calibrated to it.
2106 2106 A clock with a high error, that is, a deviation of more than 25 microseconds
2107 2107 per tick, is ignored.
2108 2108 .It Dv TIOCGPPS
2109 2109 The argument is a pointer to an
2110 2110 .Vt int ,
2111 2111 in which the state of the even handling is returned.
2112 2112 The
2113 2113 .Vt int
2114 2114 is set to a non-zero value if pulse-per-second (PPS) handling has been enabled.
2115 2115 Otherwise, it is set to zero.
2116 2116 .It Dv TIOCGSOFTCAR
2117 2117 The argument is a pointer to an
2118 2118 .Vt int
2119 2119 whose value is
2120 2120 .Sy 1
2121 2121 or
2122 2122 .Sy 0 ,
2123 2123 depending on whether the software carrier detect is turned on or off.
2124 2124 .It Dv TIOCSSOFTCAR
2125 2125 The argument is a pointer to an
2126 2126 .Vt int
2127 2127 whose value is
2128 2128 .Sy 1
2129 2129 or
2130 2130 .Sy 0 .
2131 2131 The value of the integer should be
2132 2132 .Sy 0
2133 2133 to turn off software carrier, or
2134 2134 .Sy 1
2135 2135 to turn it on.
2136 2136 .It Dv TIOCGPPSEV
2137 2137 The argument is a pointer to a
2138 2138 .Vt "struct ppsclockev" .
2139 2139 This structure contains the following members:
2140 2140 .Bd -literal -offset 2n
2141 2141 struct timeval tv;
2142 2142 uint32_t serial;
2143 2143 .Ed
2144 2144 .Pp
2145 2145 .Fa tv
2146 2146 is the system clock timestamp when the event (pulse on the
2147 2147 .Sy DCD
2148 2148 pin) occurred.
2149 2149 .Fa serial
2150 2150 is the ordinal of the event, which each consecutive event
2151 2151 being assigned the next ordinal.
2152 2152 The first event registered gets a
2153 2153 .Fa serial
2154 2154 value of
2155 2155 .Sy 1 .
2156 2156 The
2157 2157 .Dv TIOCGPPSEV
2158 2158 returns the last event registered; multiple calls will persistently return the
2159 2159 same event until a new one is registered.
2160 2160 In addition to time stamping and saving the event, if it is of
2161 2161 one-second period and of consistently high accuracy, the local system clock
2162 2162 will automatically calibrate to it.
2163 2163 .El
2164 2164 .Sh FILES
2165 2165 Files in or under
2166 2166 .Pa /dev
2167 2167 .Sh SEE ALSO
2168 2168 .Xr stty 1 ,
2169 2169 .Xr fork 2 ,
2170 2170 .Xr getpgid 2 ,
2171 2171 .Xr getsid 2 ,
2172 2172 .Xr ioctl 2 ,
2173 2173 .Xr setsid 2 ,
2174 2174 .Xr sigaction 2 ,
2175 2175 .Xr signal 3C ,
2176 2176 .Xr tcsetpgrp 3C ,
2177 2177 .Xr termios 3C ,
2178 2178 .Xr signal.h 3HEAD ,
2179 2179 .Xr streamio 7I
↓ open down ↓ |
429 lines elided |
↑ open up ↑ |
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX