1termios(3) Library Functions Manual termios(3)
2
3
4
6 termios, tcgetattr, tcsetattr, tcsendbreak, tcdrain, tcflush, tcflow,
7 cfmakeraw, cfgetospeed, cfgetispeed, cfsetispeed, cfsetospeed, cfset‐
8 speed - get and set terminal attributes, line control, get and set baud
9 rate
10
12 Standard C library (libc, -lc)
13
15 #include <termios.h>
16 #include <unistd.h>
17
18 int tcgetattr(int fd, struct termios *termios_p);
19 int tcsetattr(int fd, int optional_actions,
20 const struct termios *termios_p);
21
22 int tcsendbreak(int fd, int duration);
23 int tcdrain(int fd);
24 int tcflush(int fd, int queue_selector);
25 int tcflow(int fd, int action);
26
27 void cfmakeraw(struct termios *termios_p);
28
29 speed_t cfgetispeed(const struct termios *termios_p);
30 speed_t cfgetospeed(const struct termios *termios_p);
31
32 int cfsetispeed(struct termios *termios_p, speed_t speed);
33 int cfsetospeed(struct termios *termios_p, speed_t speed);
34 int cfsetspeed(struct termios *termios_p, speed_t speed);
35
36 Feature Test Macro Requirements for glibc (see feature_test_macros(7)):
37
38 cfsetspeed(), cfmakeraw():
39 Since glibc 2.19:
40 _DEFAULT_SOURCE
41 glibc 2.19 and earlier:
42 _BSD_SOURCE
43
45 The termios functions describe a general terminal interface that is
46 provided to control asynchronous communications ports.
47
48 The termios structure
49 Many of the functions described here have a termios_p argument that is
50 a pointer to a termios structure. This structure contains at least the
51 following members:
52
53 tcflag_t c_iflag; /* input modes */
54 tcflag_t c_oflag; /* output modes */
55 tcflag_t c_cflag; /* control modes */
56 tcflag_t c_lflag; /* local modes */
57 cc_t c_cc[NCCS]; /* special characters */
58
59 The values that may be assigned to these fields are described below.
60 In the case of the first four bit-mask fields, the definitions of some
61 of the associated flags that may be set are exposed only if a specific
62 feature test macro (see feature_test_macros(7)) is defined, as noted in
63 brackets ("[]").
64
65 In the descriptions below, "not in POSIX" means that the value is not
66 specified in POSIX.1-2001, and "XSI" means that the value is specified
67 in POSIX.1-2001 as part of the XSI extension.
68
69 c_iflag flag constants:
70
71 IGNBRK Ignore BREAK condition on input.
72
73 BRKINT If IGNBRK is set, a BREAK is ignored. If it is not set but
74 BRKINT is set, then a BREAK causes the input and output queues
75 to be flushed, and if the terminal is the controlling terminal
76 of a foreground process group, it will cause a SIGINT to be sent
77 to this foreground process group. When neither IGNBRK nor
78 BRKINT are set, a BREAK reads as a null byte ('\0'), except when
79 PARMRK is set, in which case it reads as the sequence \377 \0
80 \0.
81
82 IGNPAR Ignore framing errors and parity errors.
83
84 PARMRK If this bit is set, input bytes with parity or framing errors
85 are marked when passed to the program. This bit is meaningful
86 only when INPCK is set and IGNPAR is not set. The way erroneous
87 bytes are marked is with two preceding bytes, \377 and \0.
88 Thus, the program actually reads three bytes for one erroneous
89 byte received from the terminal. If a valid byte has the value
90 \377, and ISTRIP (see below) is not set, the program might con‐
91 fuse it with the prefix that marks a parity error. Therefore, a
92 valid byte \377 is passed to the program as two bytes, \377
93 \377, in this case.
94
95 If neither IGNPAR nor PARMRK is set, read a character with a
96 parity error or framing error as \0.
97
98 INPCK Enable input parity checking.
99
100 ISTRIP Strip off eighth bit.
101
102 INLCR Translate NL to CR on input.
103
104 IGNCR Ignore carriage return on input.
105
106 ICRNL Translate carriage return to newline on input (unless IGNCR is
107 set).
108
109 IUCLC (not in POSIX) Map uppercase characters to lowercase on input.
110
111 IXON Enable XON/XOFF flow control on output.
112
113 IXANY (XSI) Typing any character will restart stopped output. (The
114 default is to allow just the START character to restart output.)
115
116 IXOFF Enable XON/XOFF flow control on input.
117
118 IMAXBEL
119 (not in POSIX) Ring bell when input queue is full. Linux does
120 not implement this bit, and acts as if it is always set.
121
122 IUTF8 (since Linux 2.6.4)
123 (not in POSIX) Input is UTF8; this allows character-erase to be
124 correctly performed in cooked mode.
125
126 c_oflag flag constants:
127
128 OPOST Enable implementation-defined output processing.
129
130 OLCUC (not in POSIX) Map lowercase characters to uppercase on output.
131
132 ONLCR (XSI) Map NL to CR-NL on output.
133
134 OCRNL Map CR to NL on output.
135
136 ONOCR Don't output CR at column 0.
137
138 ONLRET The NL character is assumed to do the carriage-return function;
139 the kernel's idea of the current column is set to 0 after both
140 NL and CR.
141
142 OFILL Send fill characters for a delay, rather than using a timed de‐
143 lay.
144
145 OFDEL Fill character is ASCII DEL (0177). If unset, fill character is
146 ASCII NUL ('\0'). (Not implemented on Linux.)
147
148 NLDLY Newline delay mask. Values are NL0 and NL1. [requires
149 _BSD_SOURCE or _SVID_SOURCE or _XOPEN_SOURCE]
150
151 CRDLY Carriage return delay mask. Values are CR0, CR1, CR2, or CR3.
152 [requires _BSD_SOURCE or _SVID_SOURCE or _XOPEN_SOURCE]
153
154 TABDLY Horizontal tab delay mask. Values are TAB0, TAB1, TAB2, TAB3
155 (or XTABS, but see the BUGS section). A value of TAB3, that is,
156 XTABS, expands tabs to spaces (with tab stops every eight col‐
157 umns). [requires _BSD_SOURCE or _SVID_SOURCE or _XOPEN_SOURCE]
158
159 BSDLY Backspace delay mask. Values are BS0 or BS1. (Has never been
160 implemented.) [requires _BSD_SOURCE or _SVID_SOURCE or
161 _XOPEN_SOURCE]
162
163 VTDLY Vertical tab delay mask. Values are VT0 or VT1.
164
165 FFDLY Form feed delay mask. Values are FF0 or FF1. [requires
166 _BSD_SOURCE or _SVID_SOURCE or _XOPEN_SOURCE]
167
168 c_cflag flag constants:
169
170 CBAUD (not in POSIX) Baud speed mask (4+1 bits). [requires
171 _BSD_SOURCE or _SVID_SOURCE]
172
173 CBAUDEX
174 (not in POSIX) Extra baud speed mask (1 bit), included in CBAUD.
175 [requires _BSD_SOURCE or _SVID_SOURCE]
176
177 (POSIX says that the baud speed is stored in the termios struc‐
178 ture without specifying where precisely, and provides
179 cfgetispeed() and cfsetispeed() for getting at it. Some systems
180 use bits selected by CBAUD in c_cflag, other systems use sepa‐
181 rate fields, for example, sg_ispeed and sg_ospeed.)
182
183 CSIZE Character size mask. Values are CS5, CS6, CS7, or CS8.
184
185 CSTOPB Set two stop bits, rather than one.
186
187 CREAD Enable receiver.
188
189 PARENB Enable parity generation on output and parity checking for in‐
190 put.
191
192 PARODD If set, then parity for input and output is odd; otherwise even
193 parity is used.
194
195 HUPCL Lower modem control lines after last process closes the device
196 (hang up).
197
198 CLOCAL Ignore modem control lines.
199
200 LOBLK (not in POSIX) Block output from a noncurrent shell layer. For
201 use by shl (shell layers). (Not implemented on Linux.)
202
203 CIBAUD (not in POSIX) Mask for input speeds. The values for the CIBAUD
204 bits are the same as the values for the CBAUD bits, shifted left
205 IBSHIFT bits. [requires _BSD_SOURCE or _SVID_SOURCE] (Not im‐
206 plemented in glibc, supported on Linux via TCGET* and TCSET*
207 ioctls; see ioctl_tty(2))
208
209 CMSPAR (not in POSIX) Use "stick" (mark/space) parity (supported on
210 certain serial devices): if PARODD is set, the parity bit is al‐
211 ways 1; if PARODD is not set, then the parity bit is always 0.
212 [requires _BSD_SOURCE or _SVID_SOURCE]
213
214 CRTSCTS
215 (not in POSIX) Enable RTS/CTS (hardware) flow control. [re‐
216 quires _BSD_SOURCE or _SVID_SOURCE]
217
218 c_lflag flag constants:
219
220 ISIG When any of the characters INTR, QUIT, SUSP, or DSUSP are re‐
221 ceived, generate the corresponding signal.
222
223 ICANON Enable canonical mode (described below).
224
225 XCASE (not in POSIX; not supported under Linux) If ICANON is also set,
226 terminal is uppercase only. Input is converted to lowercase,
227 except for characters preceded by \. On output, uppercase char‐
228 acters are preceded by \ and lowercase characters are converted
229 to uppercase. [requires _BSD_SOURCE or _SVID_SOURCE or
230 _XOPEN_SOURCE]
231
232 ECHO Echo input characters.
233
234 ECHOE If ICANON is also set, the ERASE character erases the preceding
235 input character, and WERASE erases the preceding word.
236
237 ECHOK If ICANON is also set, the KILL character erases the current
238 line.
239
240 ECHONL If ICANON is also set, echo the NL character even if ECHO is not
241 set.
242
243 ECHOCTL
244 (not in POSIX) If ECHO is also set, terminal special characters
245 other than TAB, NL, START, and STOP are echoed as ^X, where X is
246 the character with ASCII code 0x40 greater than the special
247 character. For example, character 0x08 (BS) is echoed as ^H.
248 [requires _BSD_SOURCE or _SVID_SOURCE]
249
250 ECHOPRT
251 (not in POSIX) If ICANON and ECHO are also set, characters are
252 printed as they are being erased. [requires _BSD_SOURCE or
253 _SVID_SOURCE]
254
255 ECHOKE (not in POSIX) If ICANON is also set, KILL is echoed by erasing
256 each character on the line, as specified by ECHOE and ECHOPRT.
257 [requires _BSD_SOURCE or _SVID_SOURCE]
258
259 DEFECHO
260 (not in POSIX) Echo only when a process is reading. (Not imple‐
261 mented on Linux.)
262
263 FLUSHO (not in POSIX; not supported under Linux) Output is being
264 flushed. This flag is toggled by typing the DISCARD character.
265 [requires _BSD_SOURCE or _SVID_SOURCE]
266
267 NOFLSH Disable flushing the input and output queues when generating
268 signals for the INT, QUIT, and SUSP characters.
269
270 TOSTOP Send the SIGTTOU signal to the process group of a background
271 process which tries to write to its controlling terminal.
272
273 PENDIN (not in POSIX; not supported under Linux) All characters in the
274 input queue are reprinted when the next character is read.
275 (bash(1) handles typeahead this way.) [requires _BSD_SOURCE or
276 _SVID_SOURCE]
277
278 IEXTEN Enable implementation-defined input processing. This flag, as
279 well as ICANON must be enabled for the special characters EOL2,
280 LNEXT, REPRINT, WERASE to be interpreted, and for the IUCLC flag
281 to be effective.
282
283 The c_cc array defines the terminal special characters. The symbolic
284 indices (initial values) and meaning are:
285
286 VDISCARD
287 (not in POSIX; not supported under Linux; 017, SI, Ctrl-O) Tog‐
288 gle: start/stop discarding pending output. Recognized when IEX‐
289 TEN is set, and then not passed as input.
290
291 VDSUSP (not in POSIX; not supported under Linux; 031, EM, Ctrl-Y) De‐
292 layed suspend character (DSUSP): send SIGTSTP signal when the
293 character is read by the user program. Recognized when IEXTEN
294 and ISIG are set, and the system supports job control, and then
295 not passed as input.
296
297 VEOF (004, EOT, Ctrl-D) End-of-file character (EOF). More precisely:
298 this character causes the pending tty buffer to be sent to the
299 waiting user program without waiting for end-of-line. If it is
300 the first character of the line, the read(2) in the user program
301 returns 0, which signifies end-of-file. Recognized when ICANON
302 is set, and then not passed as input.
303
304 VEOL (0, NUL) Additional end-of-line character (EOL). Recognized
305 when ICANON is set.
306
307 VEOL2 (not in POSIX; 0, NUL) Yet another end-of-line character (EOL2).
308 Recognized when ICANON is set.
309
310 VERASE (0177, DEL, rubout, or 010, BS, Ctrl-H, or also #) Erase charac‐
311 ter (ERASE). This erases the previous not-yet-erased character,
312 but does not erase past EOF or beginning-of-line. Recognized
313 when ICANON is set, and then not passed as input.
314
315 VINTR (003, ETX, Ctrl-C, or also 0177, DEL, rubout) Interrupt charac‐
316 ter (INTR). Send a SIGINT signal. Recognized when ISIG is set,
317 and then not passed as input.
318
319 VKILL (025, NAK, Ctrl-U, or Ctrl-X, or also @) Kill character (KILL).
320 This erases the input since the last EOF or beginning-of-line.
321 Recognized when ICANON is set, and then not passed as input.
322
323 VLNEXT (not in POSIX; 026, SYN, Ctrl-V) Literal next (LNEXT). Quotes
324 the next input character, depriving it of a possible special
325 meaning. Recognized when IEXTEN is set, and then not passed as
326 input.
327
328 VMIN Minimum number of characters for noncanonical read (MIN).
329
330 VQUIT (034, FS, Ctrl-\) Quit character (QUIT). Send SIGQUIT signal.
331 Recognized when ISIG is set, and then not passed as input.
332
333 VREPRINT
334 (not in POSIX; 022, DC2, Ctrl-R) Reprint unread characters (RE‐
335 PRINT). Recognized when ICANON and IEXTEN are set, and then not
336 passed as input.
337
338 VSTART (021, DC1, Ctrl-Q) Start character (START). Restarts output
339 stopped by the Stop character. Recognized when IXON is set, and
340 then not passed as input.
341
342 VSTATUS
343 (not in POSIX; not supported under Linux; status request: 024,
344 DC4, Ctrl-T). Status character (STATUS). Display status infor‐
345 mation at terminal, including state of foreground process and
346 amount of CPU time it has consumed. Also sends a SIGINFO signal
347 (not supported on Linux) to the foreground process group.
348
349 VSTOP (023, DC3, Ctrl-S) Stop character (STOP). Stop output until
350 Start character typed. Recognized when IXON is set, and then
351 not passed as input.
352
353 VSUSP (032, SUB, Ctrl-Z) Suspend character (SUSP). Send SIGTSTP sig‐
354 nal. Recognized when ISIG is set, and then not passed as input.
355
356 VSWTCH (not in POSIX; not supported under Linux; 0, NUL) Switch charac‐
357 ter (SWTCH). Used in System V to switch shells in shell layers,
358 a predecessor to shell job control.
359
360 VTIME Timeout in deciseconds for noncanonical read (TIME).
361
362 VWERASE
363 (not in POSIX; 027, ETB, Ctrl-W) Word erase (WERASE). Recog‐
364 nized when ICANON and IEXTEN are set, and then not passed as in‐
365 put.
366
367 An individual terminal special character can be disabled by setting the
368 value of the corresponding c_cc element to _POSIX_VDISABLE.
369
370 The above symbolic subscript values are all different, except that
371 VTIME, VMIN may have the same value as VEOL, VEOF, respectively. In
372 noncanonical mode the special character meaning is replaced by the
373 timeout meaning. For an explanation of VMIN and VTIME, see the de‐
374 scription of noncanonical mode below.
375
376 Retrieving and changing terminal settings
377 tcgetattr() gets the parameters associated with the object referred by
378 fd and stores them in the termios structure referenced by termios_p.
379 This function may be invoked from a background process; however, the
380 terminal attributes may be subsequently changed by a foreground
381 process.
382
383 tcsetattr() sets the parameters associated with the terminal (unless
384 support is required from the underlying hardware that is not available)
385 from the termios structure referred to by termios_p. optional_actions
386 specifies when the changes take effect:
387
388 TCSANOW
389 the change occurs immediately.
390
391 TCSADRAIN
392 the change occurs after all output written to fd has been trans‐
393 mitted. This option should be used when changing parameters
394 that affect output.
395
396 TCSAFLUSH
397 the change occurs after all output written to the object re‐
398 ferred by fd has been transmitted, and all input that has been
399 received but not read will be discarded before the change is
400 made.
401
402 Canonical and noncanonical mode
403 The setting of the ICANON canon flag in c_lflag determines whether the
404 terminal is operating in canonical mode (ICANON set) or noncanonical
405 mode (ICANON unset). By default, ICANON is set.
406
407 In canonical mode:
408
409 • Input is made available line by line. An input line is available
410 when one of the line delimiters is typed (NL, EOL, EOL2; or EOF at
411 the start of line). Except in the case of EOF, the line delimiter
412 is included in the buffer returned by read(2).
413
414 • Line editing is enabled (ERASE, KILL; and if the IEXTEN flag is set:
415 WERASE, REPRINT, LNEXT). A read(2) returns at most one line of in‐
416 put; if the read(2) requested fewer bytes than are available in the
417 current line of input, then only as many bytes as requested are
418 read, and the remaining characters will be available for a future
419 read(2).
420
421 • The maximum line length is 4096 chars (including the terminating
422 newline character); lines longer than 4096 chars are truncated. Af‐
423 ter 4095 characters, input processing (e.g., ISIG and ECHO* process‐
424 ing) continues, but any input data after 4095 characters up to (but
425 not including) any terminating newline is discarded. This ensures
426 that the terminal can always receive more input until at least one
427 line can be read.
428
429 In noncanonical mode input is available immediately (without the user
430 having to type a line-delimiter character), no input processing is per‐
431 formed, and line editing is disabled. The read buffer will only accept
432 4095 chars; this provides the necessary space for a newline char if the
433 input mode is switched to canonical. The settings of MIN (c_cc[VMIN])
434 and TIME (c_cc[VTIME]) determine the circumstances in which a read(2)
435 completes; there are four distinct cases:
436
437 MIN == 0, TIME == 0 (polling read)
438 If data is available, read(2) returns immediately, with the
439 lesser of the number of bytes available, or the number of bytes
440 requested. If no data is available, read(2) returns 0.
441
442 MIN > 0, TIME == 0 (blocking read)
443 read(2) blocks until MIN bytes are available, and returns up to
444 the number of bytes requested.
445
446 MIN == 0, TIME > 0 (read with timeout)
447 TIME specifies the limit for a timer in tenths of a second. The
448 timer is started when read(2) is called. read(2) returns either
449 when at least one byte of data is available, or when the timer
450 expires. If the timer expires without any input becoming avail‐
451 able, read(2) returns 0. If data is already available at the
452 time of the call to read(2), the call behaves as though the data
453 was received immediately after the call.
454
455 MIN > 0, TIME > 0 (read with interbyte timeout)
456 TIME specifies the limit for a timer in tenths of a second.
457 Once an initial byte of input becomes available, the timer is
458 restarted after each further byte is received. read(2) returns
459 when any of the following conditions is met:
460
461 • MIN bytes have been received.
462
463 • The interbyte timer expires.
464
465 • The number of bytes requested by read(2) has been received.
466 (POSIX does not specify this termination condition, and on
467 some other implementations read(2) does not return in this
468 case.)
469
470 Because the timer is started only after the initial byte becomes
471 available, at least one byte will be read. If data is already
472 available at the time of the call to read(2), the call behaves
473 as though the data was received immediately after the call.
474
475 POSIX does not specify whether the setting of the O_NONBLOCK file sta‐
476 tus flag takes precedence over the MIN and TIME settings. If O_NON‐
477 BLOCK is set, a read(2) in noncanonical mode may return immediately,
478 regardless of the setting of MIN or TIME. Furthermore, if no data is
479 available, POSIX permits a read(2) in noncanonical mode to return ei‐
480 ther 0, or -1 with errno set to EAGAIN.
481
482 Raw mode
483 cfmakeraw() sets the terminal to something like the "raw" mode of the
484 old Version 7 terminal driver: input is available character by charac‐
485 ter, echoing is disabled, and all special processing of terminal input
486 and output characters is disabled. The terminal attributes are set as
487 follows:
488
489 termios_p->c_iflag &= ~(IGNBRK | BRKINT | PARMRK | ISTRIP
490 | INLCR | IGNCR | ICRNL | IXON);
491 termios_p->c_oflag &= ~OPOST;
492 termios_p->c_lflag &= ~(ECHO | ECHONL | ICANON | ISIG | IEXTEN);
493 termios_p->c_cflag &= ~(CSIZE | PARENB);
494 termios_p->c_cflag |= CS8;
495
496 Line control
497 tcsendbreak() transmits a continuous stream of zero-valued bits for a
498 specific duration, if the terminal is using asynchronous serial data
499 transmission. If duration is zero, it transmits zero-valued bits for
500 at least 0.25 seconds, and not more than 0.5 seconds. If duration is
501 not zero, it sends zero-valued bits for some implementation-defined
502 length of time.
503
504 If the terminal is not using asynchronous serial data transmission, tc‐
505 sendbreak() returns without taking any action.
506
507 tcdrain() waits until all output written to the object referred to by
508 fd has been transmitted.
509
510 tcflush() discards data written to the object referred to by fd but not
511 transmitted, or data received but not read, depending on the value of
512 queue_selector:
513
514 TCIFLUSH
515 flushes data received but not read.
516
517 TCOFLUSH
518 flushes data written but not transmitted.
519
520 TCIOFLUSH
521 flushes both data received but not read, and data written but
522 not transmitted.
523
524 tcflow() suspends transmission or reception of data on the object re‐
525 ferred to by fd, depending on the value of action:
526
527 TCOOFF suspends output.
528
529 TCOON restarts suspended output.
530
531 TCIOFF transmits a STOP character, which stops the terminal device from
532 transmitting data to the system.
533
534 TCION transmits a START character, which starts the terminal device
535 transmitting data to the system.
536
537 The default on open of a terminal file is that neither its input nor
538 its output is suspended.
539
540 Line speed
541 The baud rate functions are provided for getting and setting the values
542 of the input and output baud rates in the termios structure. The new
543 values do not take effect until tcsetattr() is successfully called.
544
545 Setting the speed to B0 instructs the modem to "hang up". The actual
546 bit rate corresponding to B38400 may be altered with setserial(8).
547
548 The input and output baud rates are stored in the termios structure.
549
550 cfgetospeed() returns the output baud rate stored in the termios struc‐
551 ture pointed to by termios_p.
552
553 cfsetospeed() sets the output baud rate stored in the termios structure
554 pointed to by termios_p to speed, which must be one of these constants:
555
556 B0
557 B50
558 B75
559 B110
560 B134
561 B150
562 B200
563 B300
564 B600
565 B1200
566 B1800
567 B2400
568 B4800
569 B9600
570 B19200
571 B38400
572 B57600
573 B115200
574 B230400
575 B460800
576 B500000
577 B576000
578 B921600
579 B1000000
580 B1152000
581 B1500000
582 B2000000
583
584 These constants are additionally supported on the SPARC architecture:
585
586 B76800
587 B153600
588 B307200
589 B614400
590
591 These constants are additionally supported on non-SPARC architectures:
592
593 B2500000
594 B3000000
595 B3500000
596 B4000000
597
598 Due to differences between architectures, portable applications should
599 check if a particular Bnnn constant is defined prior to using it.
600
601 The zero baud rate, B0, is used to terminate the connection. If B0 is
602 specified, the modem control lines shall no longer be asserted. Nor‐
603 mally, this will disconnect the line. CBAUDEX is a mask for the speeds
604 beyond those defined in POSIX.1 (57600 and above). Thus, B57600 &
605 CBAUDEX is nonzero.
606
607 Setting the baud rate to a value other than those defined by Bnnn con‐
608 stants is possible via the TCSETS2 ioctl; see ioctl_tty(2).
609
610 cfgetispeed() returns the input baud rate stored in the termios struc‐
611 ture.
612
613 cfsetispeed() sets the input baud rate stored in the termios structure
614 to speed, which must be specified as one of the Bnnn constants listed
615 above for cfsetospeed(). If the input baud rate is set to the literal
616 constant 0 (not the symbolic constant B0), the input baud rate will be
617 equal to the output baud rate.
618
619 cfsetspeed() is a 4.4BSD extension. It takes the same arguments as cf‐
620 setispeed(), and sets both input and output speed.
621
623 cfgetispeed() returns the input baud rate stored in the termios struc‐
624 ture.
625
626 cfgetospeed() returns the output baud rate stored in the termios struc‐
627 ture.
628
629 All other functions return:
630
631 0 on success.
632
633 -1 on failure and set errno to indicate the error.
634
635 Note that tcsetattr() returns success if any of the requested changes
636 could be successfully carried out. Therefore, when making multiple
637 changes it may be necessary to follow this call with a further call to
638 tcgetattr() to check that all changes have been performed successfully.
639
641 For an explanation of the terms used in this section, see at‐
642 tributes(7).
643
644 ┌────────────────────────────────────────────┬───────────────┬─────────┐
645 │Interface │ Attribute │ Value │
646 ├────────────────────────────────────────────┼───────────────┼─────────┤
647 │tcgetattr(), tcsetattr(), tcdrain(), │ Thread safety │ MT-Safe │
648 │tcflush(), tcflow(), tcsendbreak(), │ │ │
649 │cfmakeraw(), cfgetispeed(), cfgetospeed(), │ │ │
650 │cfsetispeed(), cfsetospeed(), cfsetspeed() │ │ │
651 └────────────────────────────────────────────┴───────────────┴─────────┘
652
654 tcgetattr()
655 tcsetattr()
656 tcsendbreak()
657 tcdrain()
658 tcflush()
659 tcflow()
660 cfgetispeed()
661 cfgetospeed()
662 cfsetispeed()
663 cfsetospeed()
664 POSIX.1-2008.
665
666 cfmakeraw()
667 cfsetspeed()
668 BSD.
669
671 tcgetattr()
672 tcsetattr()
673 tcsendbreak()
674 tcdrain()
675 tcflush()
676 tcflow()
677 cfgetispeed()
678 cfgetospeed()
679 cfsetispeed()
680 cfsetospeed()
681 POSIX.1-2001.
682
683 cfmakeraw()
684 cfsetspeed()
685 BSD.
686
688 UNIX V7 and several later systems have a list of baud rates where after
689 the values B0 through B9600 one finds the two constants EXTA, EXTB
690 ("External A" and "External B"). Many systems extend the list with
691 much higher baud rates.
692
693 The effect of a nonzero duration with tcsendbreak() varies. SunOS
694 specifies a break of duration * N seconds, where N is at least 0.25,
695 and not more than 0.5. Linux, AIX, DU, Tru64 send a break of duration
696 milliseconds. FreeBSD and NetBSD and HP-UX and MacOS ignore the value
697 of duration. Under Solaris and UnixWare, tcsendbreak() with nonzero
698 duration behaves like tcdrain().
699
701 On the Alpha architecture before Linux 4.16 (and glibc before glibc
702 2.28), the XTABS value was different from TAB3 and it was ignored by
703 the N_TTY line discipline code of the terminal driver as a result
704 (because as it wasn't part of the TABDLY mask).
705
707 reset(1), setterm(1), stty(1), tput(1), tset(1), tty(1),
708 ioctl_console(2), ioctl_tty(2), cc_t(3type), speed_t(3type),
709 tcflag_t(3type), setserial(8)
710
711
712
713Linux man-pages 6.05 2023-07-30 termios(3)