1TERMIOS(3)                 Linux Programmer's Manual                TERMIOS(3)
2
3
4

NAME

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

SYNOPSIS

12       #include <termios.h>
13       #include <unistd.h>
14
15       int tcgetattr(int fd, struct termios *termios_p);
16       int tcsetattr(int fd, int optional_actions,
17                     const struct termios *termios_p);
18
19       int tcsendbreak(int fd, int duration);
20       int tcdrain(int fd);
21       int tcflush(int fd, int queue_selector);
22       int tcflow(int fd, int action);
23
24       void cfmakeraw(struct termios *termios_p);
25
26       speed_t cfgetispeed(const struct termios *termios_p);
27       speed_t cfgetospeed(const struct termios *termios_p);
28
29       int cfsetispeed(struct termios *termios_p, speed_t speed);
30       int cfsetospeed(struct termios *termios_p, speed_t speed);
31       int cfsetspeed(struct termios *termios_p, speed_t speed);
32
33   Feature Test Macro Requirements for glibc (see feature_test_macros(7)):
34
35       cfsetspeed(), cfmakeraw():
36           Since glibc 2.19:
37               _DEFAULT_SOURCE
38           Glibc 2.19 and earlier:
39               _BSD_SOURCE
40

DESCRIPTION

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

RETURN VALUE

587       cfgetispeed() returns the input baud rate stored in the termios  struc‐
588       ture.
589
590       cfgetospeed() returns the output baud rate stored in the termios struc‐
591       ture.
592
593       All other functions return:
594
595       0      on success.
596
597       -1     on failure and set errno to indicate the error.
598
599       Note that tcsetattr() returns success if any of the  requested  changes
600       could  be  successfully  carried  out.  Therefore, when making multiple
601       changes it may be necessary to follow this call with a further call  to
602       tcgetattr() to check that all changes have been performed successfully.
603

ATTRIBUTES

605       For  an  explanation  of  the  terms  used  in  this  section,  see at‐
606       tributes(7).
607
608       ┌────────────────────────────────────────────┬───────────────┬─────────┐
609Interface                                   Attribute     Value   
610       ├────────────────────────────────────────────┼───────────────┼─────────┤
611tcgetattr(), tcsetattr(), tcdrain(),        │ Thread safety │ MT-Safe │
612tcflush(), tcflow(), tcsendbreak(),         │               │         │
613cfmakeraw(), cfgetispeed(), cfgetospeed(),  │               │         │
614cfsetispeed(), cfsetospeed(), cfsetspeed()  │               │         │
615       └────────────────────────────────────────────┴───────────────┴─────────┘
616

CONFORMING TO

618       tcgetattr(),    tcsetattr(),   tcsendbreak(),   tcdrain(),   tcflush(),
619       tcflow(),  cfgetispeed(),  cfgetospeed(),  cfsetispeed(),   and   cfse‐
620       tospeed() are specified in POSIX.1-2001.
621
622       cfmakeraw()  and cfsetspeed() are nonstandard, but available on the BS‐
623       Ds.
624

NOTES

626       UNIX V7 and several later systems have a list of baud rates where after
627       the  fourteen  values  B0, ..., B9600 one finds the two constants EXTA,
628       EXTB ("External A" and "External B").  Many  systems  extend  the  list
629       with much higher baud rates.
630
631       The  effect  of  a  nonzero  duration with tcsendbreak() varies.  SunOS
632       specifies a break of duration * N seconds, where N is  at  least  0.25,
633       and  not more than 0.5.  Linux, AIX, DU, Tru64 send a break of duration
634       milliseconds.  FreeBSD and NetBSD and HP-UX and MacOS ignore the  value
635       of  duration.   Under  Solaris and UnixWare, tcsendbreak() with nonzero
636       duration behaves like tcdrain().
637

BUGS

639       On the Alpha architecture before Linux 4.16 (and  glibc  before  2.28),
640       the XTABS value was different from TAB3 and it was ignored by the N_TTY
641       line discipline code of the terminal driver as a result (because as  it
642       wasn't part of the TABDLY mask).
643

SEE ALSO

645       reset(1),  setterm(1),  stty(1),  tput(1),  tset(1), tty(1), ioctl_con‐
646       sole(2), ioctl_tty(2), setserial(8)
647

COLOPHON

649       This page is part of release 5.12 of the Linux  man-pages  project.   A
650       description  of  the project, information about reporting bugs, and the
651       latest    version    of    this    page,    can     be     found     at
652       https://www.kernel.org/doc/man-pages/.
653
654
655
656Linux                             2021-03-22                        TERMIOS(3)
Impressum