Penguin
Blame: tcgetattr(3)
EditPageHistoryDiffInfoLikePages
Annotated edit history of tcgetattr(3) version 1, including all changes. View license author blame.
Rev Author # Line
1 perry 1 TERMIOS
2 !!!TERMIOS
3 NAME
4 SYNOPSIS
5 DESCRIPTION
6 RETURN VALUE
7 SEE ALSO
8 ----
9 !!NAME
10
11
12 termios, tcgetattr, tcsetattr, tcsendbreak, tcdrain, tcflush, tcflow, cfmakeraw, cfgetospeed, cfgetispeed, cfsetispeed, cfsetospeed, tcgetpgrp, tcsetpgrp - get and set terminal attributes, line control, get and set baud rate, get and set terminal foreground process group ID
13 !!SYNOPSIS
14
15
16 __#include __
17 #include __
18
19
20 __int tcgetattr ( int__ ''fd''__, struct termios
21 *__''termios_p'' __);__
22
23
24 __int tcsetattr ( int__ ''fd''__, int__
25 ''optional_actions''__, struct termios
26 *__''termios_p'' __);__
27
28
29 __int tcsendbreak ( int__ ''fd''__, int__
30 ''duration'' __);__
31
32
33 __int tcdrain ( int__ ''fd'' __);__
34
35
36 __int tcflush ( int__ ''fd''__, int__
37 ''queue_selector'' __);__
38
39
40 __int tcflow ( int__ ''fd''__, int__ ''action''
41 __);__
42
43
44 __int cfmakeraw ( struct termios *__''termios_p''
45 __);__
46
47
48 __speed_t cfgetospeed ( struct termios
49 *__''termios_p'' __);__
50
51
52 __int cfsetospeed ( struct termios
53 *__''termios_p''__, speed_t__ ''speed''
54 __);__
55
56
57 __speed_t cfgetispeed ( struct termios
58 *__''termios_p'' __);__
59
60
61 __int cfsetispeed ( struct termios
62 *__''termios_p''__, speed_t__ ''speed''
63 __);__
64
65
66 __pid_t tcgetpgrp ( int__ ''fd''
67 __);__
68
69
70 __int tcsetpgrp ( int__ ''fd''__, pid_t__
71 ''pgrpid'' __);__
72 !!DESCRIPTION
73
74
75 The termios functions describe a general terminal interface
76 that is provided to control asynchronous communications
77 ports.
78
79
80 Many of the functions described here have a ''termios_p''
81 argument that is a pointer to a __termios__ structure.
82 This structure contains the following members:
83
84
85 tcflag_t ''c_iflag''; /* input modes */
86 tcflag_t ''c_oflag''; /* output modes */
87 tcflag_t ''c_cflag''; /* control modes */
88 tcflag_t ''c_lflag''; /* local modes */
89 cc_t ''c_cc''[[__NCCS__]; /* control chars */
90
91
92 ''c_iflag'' flag constants:
93
94
95 __IGNBRK__
96
97
98 ignore BREAK condition on input
99
100
101 __BRKINT__
102
103
104 If __IGNBRK__ is not set, generate __SIGINT__ on BREAK
105 condition, else read BREAK as character 0.
106
107
108 __IGNPAR__
109
110
111 ignore framing errors and parity errors.
112
113
114 __PARMRK__
115
116
117 if __IGNPAR__ is not set, prefix a character with a
118 parity error or framing error with 377 0. If neither
119 __IGNPAR__ nor __PARMRK__ is set, read a character
120 with a parity error or framing error as 0.
121
122
123 __INPCK__
124
125
126 enable input parity checking
127
128
129 __ISTRIP__
130
131
132 strip off eighth bit
133
134
135 __INLCR__
136
137
138 translate NL to CR on input
139
140
141 __IGNCR__
142
143
144 ignore carriage return on input
145
146
147 __ICRNL__
148
149
150 translate carriage return to newline on input (unless
151 __IGNCR__ is set)
152
153
154 __IUCLC__
155
156
157 map uppercase characters to lowercase on input
158
159
160 __IXON__
161
162
163 enable XON/XOFF flow control on output
164
165
166 __IXANY__
167
168
169 enable any character to restart output
170
171
172 __IXOFF__
173
174
175 enable XON/XOFF flow control on input
176
177
178 __IMAXBEL__
179
180
181 ring bell when input queue is full
182
183
184 ''c_oflag'' flag constants:
185
186
187 __OPOST__
188
189
190 enable implementation-defined output processing
191
192
193 __OLCUC__
194
195
196 map lowercase characters to uppercase on output
197
198
199 __ONLCR__
200
201
202 map NL to CR-NL on output
203
204
205 __OCRNL__
206
207
208 map CR to NL on output
209
210
211 __ONOCR__
212
213
214 don't output CR at column 0
215
216
217 __ONLRET__
218
219
220 don't output CR
221
222
223 __OFILL__
224
225
226 send fill characters for a delay, rather than using a timed
227 delay
228
229
230 __OFDEL__
231
232
233 fill character is ASCII DEL. If unset, fill character is
234 ASCII NUL
235
236
237 __NLDLY__
238
239
240 newline delay mask. Values are __NL0__ and
241 __NL1__.
242
243
244 __CRDLY__
245
246
247 carriage return delay mask. Values are __CR0__,
248 __CR1__, __CR2__, or __CR3__.
249
250
251 __TABDLY__
252
253
254 horizontal tab delay mask. Values are __TAB0__,
255 __TAB1__, __TAB2__, __TAB3__, or __XTABS__. A
256 value of XTABS expands tabs to spaces (with tab stops every
257 eight columns).
258
259
260 __BSDLY__
261
262
263 backspace delay mask. Values are __BS0__ or
264 __BS1__.
265
266
267 __VTDLY__
268
269
270 vertical tab delay mask. Values are __VT0__ or
271 __VT1__.
272
273
274 __FFDLY__
275
276
277 form feed delay mask. Values are __FF0__ or
278 __FF1__.
279
280
281 ''c_cflag'' flag constants:
282
283
284 __CSIZE__
285
286
287 character size mask. Values are __CS5__, __CS6__,
288 __CS7__, or __CS8__.
289
290
291 __CSTOPB__
292
293
294 set two stop bits, rather than one.
295
296
297 __CREAD__
298
299
300 enable receiver.
301
302
303 __PARENB__
304
305
306 enable parity generation on output and parity checking for
307 input.
308
309
310 __PARODD__
311
312
313 parity for input and output is odd.
314
315
316 __HUPCL__
317
318
319 lower modem control lines after last process closes the
320 device (hang up).
321
322
323 __CLOCAL__
324
325
326 ignore modem control lines
327
328
329 __CIBAUD__
330
331
332 mask for input speeds (not used).
333
334
335 __CRTSCTS__
336
337
338 flow control.
339
340
341 ''c_lflag'' flag constants:
342
343
344 __ISIG__
345
346
347 when any of the characters INTR, QUIT, SUSP, or DSUSP are
348 received, generate the corresponding signal.
349
350
351 __ICANON__
352
353
354 enable canonical mode. This enables the special characters
355 EOF, EOL, EOL2, ERASE, KILL, REPRINT, STATUS, and WERASE,
356 and buffers by lines.
357
358
359 __XCASE__
360
361
362 if __ICANON__ is also set, terminal is uppercase only.
363 Input is converted to lowercase, except for characters
364 preceded by . On output, uppercase characters are preceded
365 by \ and lowercase characters are converted to
366 uppercase.
367
368
369 __ECHO__
370
371
372 echo input characters.
373
374
375 __ECHOE__
376
377
378 if __ICANON__ is also set, the ERASE character erases the
379 preceding input character, and WERASE erases the preceding
380 word.
381
382
383 __ECHOK__
384
385
386 if __ICANON__ is also set, the KILL character erases the
387 current line.
388
389
390 __ECHONL__
391
392
393 if __ICANON__ is also set, echo the NL character even if
394 ECHO is not set.
395
396
397 __ECHOCTL__
398
399
400 if __ECHO__ is also set, ASCII control signals other than
401 TAB, NL, START, and STOP are echoed as ^X, where X is the
402 character with ASCII code 0x40 greater than the control
403 signal. For example, character 0x08 (BS) is echoed as
404 ^H.
405
406
407 __ECHOPRT__
408
409
410 if __ICANON__ and __IECHO__ are also set, characters
411 are printed as they are being erased.
412
413
414 __ECHOKE__
415
416
417 if __ICANON__ is also set, KILL is echoed by erasing each
418 character on the line, as specified by __ECHOE__ and
419 __ECHOPRT__.
420
421
422 __FLUSHO__
423
424
425 output is being flushed. This flag is toggled by typing the
426 DISCARD character.
427
428
429 __NOFLSH__
430
431
432 disable flushing the input and output queues when generating
433 the SIGINT and SIGQUIT signals, and flushing the input queue
434 when generating the SIGSUSP signal.
435
436
437 __TOSTOP__
438
439
440 send the SIGTTOU signal to the process group of a background
441 process which tries to write to its controlling
442 terminal.
443
444
445 __PENDIN__
446
447
448 all characters in the input queue are reprinted when the
449 next character is read. (__bash__ handles typeahead this
450 way.)
451
452
453 __IEXTEN__
454
455
456 enable implementation-defined input processing.
457
458
459 The ''c_cc'' array defines the special control
460 characters. The symbolic indices (and meaning: initial
461 values) are: VINTR (interrupt character: 0177, DEL, rubout),
462 VQUIT (quit character: 034, FS, Ctrl-), VERASE (erase
463 character: 010, BS, Ctrl-H), VKILL (kill character: 025,
464 NAK, Ctrl-U), VEOF (end-of-file character: 004, EOT,
465 Ctrl-D), VMIN, VEOL (additional end-of-line character: 0,
466 NUL), VTIME, VEOL2 (yet another end-of-line character: 0,
467 NUL), VSWTCH (switch character: 0, NUL), VSTART (start
468 character: 021, DC1, Ctrl-Q), VSTOP (stop character: 023,
469 DC3, Ctrl-S), VSUSP (suspend character: 032, SUB, Ctrl-Z),
470 VDSUSP (delayed suspend character: 031, EM, Ctrl-Y), VLNEXT
471 (literal next: 026, SYN, Ctrl-V), VWERASE (word erase: 027,
472 ETB, Ctrl-W), VREPRINT (reprint unread characters: 022, DC2,
473 Ctrl-R), VDISCARD (discard pending output: 017, SI,
474 Ctrl-O).
475
476
477 These symbolic subscript values are all different, except
478 that VTIME, VMIN may have the same value as VEOL, VEOF,
479 respectively. (In non-canonical mode the special character
480 meaning is replaced by the timeout meaning. MIN represents
481 the minimum number of characters that should be received to
482 satisfy the read. TIME is a decisecond-valued timer. When
483 both are set, a read will wait until at least one character
484 has been received, and then return as soon as either MIN
485 characters have been received or time TIME has passed since
486 the last character was received. If only MIN is set, the
487 read will not return before MIN characters have been
488 received. If only TIME is set, the read will return as soon
489 as either at least one character has been received, or the
490 timer times out. If neither is set, the read will return
491 immediately, only giving the currently already available
492 characters.)
493
494
495 __tcgetattr()__ gets the parameters associated with the
496 object referred by ''fd'' and stores them in the
497 __termios__ structure referenced by ''termios_p''.
498 This function may be invoked from a background process;
499 however, the terminal attributes may be subsequently changed
500 by a foreground process.
501
502
503 __tcsetattr()__ sets the parameters associated with the
504 terminal (unless support is required from the underlying
505 hardware that is not available) from the __termios__
506 structure referred to by ''termios_p''.
507 ''optional_actions'' specifies when the changes take
508 effect:
509
510
511 __TCSANOW__
512
513
514 the change occurs immediately.
515
516
517 __TCSADRAIN__
518
519
520 the change occurs after all output written to ''fd'' has
521 been transmitted. This function should be used when changing
522 parameters that affect output.
523
524
525 __TCSAFLUSH__
526
527
528 the change occurs after all output written to the object
529 referred by ''fd'' has been transmitted, and all input
530 that has been received but not read will be discarded before
531 the change is made.
532
533
534 __tcsendbreak()__ transmits a continuous stream of
535 zero-valued bits for a specific duration, if the terminal is
536 using asynchronous serial data transmission. If
537 ''duration'' is zero, it transmits zero-valued bits for
538 at least 0.25 seconds, and not more that 0.5 seconds. If
539 ''duration'' is not zero, it sends zero-valued bits for
540 ''duration''__*__''N'' seconds, where ''N'' is
541 at least 0.25, and not more than 0.5.
542
543
544 If the terminal is not using asynchronous serial data
545 transmission, __tcsendbreak()__ returns without taking
546 any action.
547
548
549 __tcdrain()__ waits until all output written to the
550 object referred to by ''fd'' has been
551 transmitted.
552
553
554 __tcflush()__ discards data written to the object
555 referred to by ''fd'' but not transmitted, or data
556 received but not read, depending on the value of
557 ''queue_selector'':
558
559
560 __TCIFLUSH__
561
562
563 flushes data received but not read.
564
565
566 __TCOFLUSH__
567
568
569 flushes data written but not transmitted.
570
571
572 __TCIOFLUSH__
573
574
575 flushes both data received but not read, and data written
576 but not transmitted.
577
578
579 __tcflow()__ suspends transmission or reception of data
580 on the object referred to by ''fd'', depending on the
581 value of ''action'':
582
583
584 __TCOOFF__
585
586
587 suspends output.
588
589
590 __TCOON__
591
592
593 restarts suspended output.
594
595
596 __TCIOFF__
597
598
599 transmits a STOP character, which stops the terminal device
600 from transmitting data to the system.
601
602
603 __TCION__
604
605
606 transmits a START character, which starts the terminal
607 device transmitting data to the system.
608
609
610 The default on open of a terminal file is that neither its
611 input nor its output is suspended.
612
613
614 The baud rate functions are provided for getting and setting
615 the values of the input and output baud rates in the
616 __termios__ structure. The new values do not take effect
617 until __tcsetattr()__ is successfully
618 called.
619
620
621 Setting the speed to __B0__ instructs the modem to
622 __B38400__ may be altered with
623 setserial(8).
624
625
626 The input and output baud rates are stored in the
627 __termios__ structure.
628
629
630 __cfmakeraw__ sets the terminal attributes as
631 follows:
632
633
634 termios_p-
635 __cfgetospeed()__ returns the output baud rate stored in the __termios__ structure pointed to by ''termios_p''.
636
637
638 __cfsetospeed()__ sets the output baud rate stored in the
639 __termios__ structure pointed to by ''termios_p'' to
640 ''speed'', which must be one of these
641 constants:
642
643
644 __ B0
645 B50
646 B75
647 B110
648 B134
649 B150
650 B200
651 B300
652 B600
653 B1200
654 B1800
655 B2400
656 B4800
657 B9600
658 B19200
659 B38400
660 B57600
661 B115200
662 B230400
663 __The zero baud rate, __B0__, is used to terminate the connection. If B0 is specified, the modem control lines shall no longer be asserted. Normally, this will disconnect the line. __CBAUDEX__ is a mask for the speeds beyond those defined in POSIX.1 (57600 and above). Thus, __B57600__ __CBAUDEX__ is nonzero.
664
665
666 __cfgetispeed()__ returns the input baud rate stored in
667 the __termios__ structure.
668
669
670 __cfsetispeed()__ sets the input baud rate stored in the
671 __termios__ structure to ''speed''. If the input baud
672 rate is set to zero, the input baud rate will be equal to
673 the output baud rate.
674
675
676 __tcgetpgrp()__ returns process group ID of foreground
677 processing group, or -1 on error.
678
679
680 __tcsetpgrp()__ sets process group ID to ''pgrpid''.
681 ''pgrpid'' must be the ID of a process group in the same
682 session.
683 !!RETURN VALUE
684
685
686 __cfgetispeed()__ returns the input baud rate stored in
687 the __termios__ structure.
688
689
690 __cfgetospeed()__ returns the output baud rate stored in
691 the __termios__ structure.
692
693
694 __tcgetpgrp()__ returns process group ID of foreground
695 processing group, or -1 on error.
696
697
698 All other functions return:
699
700
701 0
702
703
704 on success.
705
706
707 -1
708
709
710 on failure and set ''errno'' to indicate the
711 error.
712 !!SEE ALSO
713
714
715 setserial(8)
716 ----
This page is a man page (or other imported legacy content). We are unable to automatically determine the license status of this page.