]> git.ipfire.org Git - thirdparty/man-pages.git/blame - man3/termios.3
ffix
[thirdparty/man-pages.git] / man3 / termios.3
CommitLineData
fea681da
MK
1.\" Hey Emacs! This file is -*- nroff -*- source.
2.\"
3.\" Copyright (c) 1993 Michael Haardt
4.\" (michael@moria.de)
5.\" Fri Apr 2 11:32:09 MET DST 1993
6.\"
7.\" This is free documentation; you can redistribute it and/or
8.\" modify it under the terms of the GNU General Public License as
9.\" published by the Free Software Foundation; either version 2 of
10.\" the License, or (at your option) any later version.
11.\"
12.\" The GNU General Public License's references to "object code"
13.\" and "executables" are to be interpreted as the output of any
14.\" document formatting or typesetting system, including
15.\" intermediate and printed output.
16.\"
17.\" This manual is distributed in the hope that it will be useful,
18.\" but WITHOUT ANY WARRANTY; without even the implied warranty of
19.\" MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20.\" GNU General Public License for more details.
21.\"
22.\" You should have received a copy of the GNU General Public
23.\" License along with this manual; if not, write to the Free
24.\" Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111,
25.\" USA.
26.\"
27.\" Modified 1993-07-24 by Rik Faith <faith@cs.unc.edu>
28.\" Modified 1995-02-25 by Jim Van Zandt <jrv@vanzandt.mv.com>
29.\" Modified 1995-09-02 by Jim Van Zandt <jrv@vanzandt.mv.com>
30.\" moved to man3, aeb, 950919
305a0578 31.\" Modified 2001-09-22 by Michael Kerrisk <mtk-manpages@gmx.net>
fea681da
MK
32.\" Modified 2001-12-17, aeb
33.\" Modified 2004-10-31, aeb
19ab0376
MK
34.\" 2006-12-28, mtk:
35.\" Added .SS headers to give some structure to this page; and a
36.\" small amount of reordering.
37.\" Added a section on canonical and non-canonical mode.
38.\" Enhanced the discussion of "raw" mode for cfmakeraw().
39.\" Document CMSPAR.
fea681da
MK
40.\"
41.TH TERMIOS 3 2004-10-31 "Linux" "Linux Programmer's Manual"
42.SH NAME
43termios, tcgetattr, tcsetattr, tcsendbreak, tcdrain, tcflush, tcflow,
44cfmakeraw, cfgetospeed, cfgetispeed, cfsetispeed, cfsetospeed, cfsetspeed \-
45get and set terminal attributes, line control, get and set baud rate
46.SH SYNOPSIS
47.ad l
48.ft B
49#include <termios.h>
50.br
51#include <unistd.h>
52.sp
53.BI "int tcgetattr(int " fd ", struct termios *" termios_p );
54.sp
55.BI "int tcsetattr(int " fd ", int " optional_actions ", const struct termios *" termios_p );
56.sp
57.BI "int tcsendbreak(int " fd ", int " duration );
58.sp
59.BI "int tcdrain(int " fd );
60.sp
61.BI "int tcflush(int " fd ", int " queue_selector );
62.sp
63.BI "int tcflow(int " fd ", int " action );
64.sp
65.BI "void cfmakeraw(struct termios *" termios_p );
66.sp
67.BI "speed_t cfgetispeed(const struct termios *" termios_p );
68.sp
69.BI "speed_t cfgetospeed(const struct termios *" termios_p );
70.sp
71.BI "int cfsetispeed(struct termios *" termios_p ", speed_t " speed );
72.sp
73.BI "int cfsetospeed(struct termios *" termios_p ", speed_t " speed );
74.ft P
75.ad b
76.SH DESCRIPTION
77The termios functions describe a general terminal interface that is
78provided to control asynchronous communications ports.
87d1fd87 79.SS "The termios structure"
fea681da
MK
80.LP
81Many of the functions described here have a \fItermios_p\fP argument
869ebe5b 82that is a pointer to a \fItermios\fP structure. This structure contains
fea681da
MK
83at least the following members:
84.ne 9
85.sp
86.RS
87.nf
88tcflag_t \fIc_iflag\fP; /* input modes */
89tcflag_t \fIc_oflag\fP; /* output modes */
90tcflag_t \fIc_cflag\fP; /* control modes */
91tcflag_t \fIc_lflag\fP; /* local modes */
869ebe5b 92cc_t \fIc_cc\fP[\fBNCCS\fP]; /* control chars */
fea681da
MK
93.fi
94.RE
95.PP
869ebe5b
MK
96The values that may be assigned to these fields are described below.
97In the case of the first four bit-mask fields,
98the definitions of some of the associated flags that may be set are
99only exposed if a specific feature test macro (see
a8e7c990 100.BR feature_test_macros (7))
869ebe5b
MK
101is defined, as noted in brackets ("[]").
102.PP
42b09930
MK
103In the descriptions below, "not in POSIX" means that the
104value is not specified in POSIX.1-2001,
105and "XSI" means that the value is specified in POSIX.1-2001
106as part of the XSI extension.
107.PP
fea681da
MK
108\fIc_iflag\fP flag constants:
109.TP
110.B IGNBRK
111Ignore BREAK condition on input.
112.TP
113.B BRKINT
114If \fBIGNBRK\fP is set, a BREAK is ignored. If it is not set
115but \fBBRKINT\fP is set, then a BREAK causes the input and output
116queues to be flushed, and if the terminal is the controlling
117terminal of a foreground process group, it will cause a
118\fBSIGINT\fP to be sent to this foreground process group.
119When neither \fBIGNBRK\fP nor \fBBRKINT\fP are set, a BREAK
28d88c17 120reads as a null byte ('\\0'), except when \fBPARMRK\fP is set,
fea681da
MK
121in which case it reads as the sequence \\377 \\0 \\0.
122.TP
123.B IGNPAR
124Ignore framing errors and parity errors.
125.TP
126.B PARMRK
127If \fBIGNPAR\fP is not set, prefix a character with a parity error or
128framing error with \\377 \\0. If neither \fBIGNPAR\fP nor \fBPARMRK\fP
129is set, read a character with a parity error or framing error
130as \\0.
131.TP
132.B INPCK
133Enable input parity checking.
134.TP
135.B ISTRIP
136Strip off eighth bit.
137.TP
138.B INLCR
139Translate NL to CR on input.
140.TP
141.B IGNCR
142Ignore carriage return on input.
143.TP
144.B ICRNL
145Translate carriage return to newline on input (unless \fBIGNCR\fP is set).
146.TP
147.B IUCLC
148(not in POSIX) Map uppercase characters to lowercase on input.
149.TP
150.B IXON
151Enable XON/XOFF flow control on output.
152.TP
153.B IXANY
42b09930
MK
154(XSI) Typing any character will restart stopped output.
155(The default is to allow just the START character to restart output.)
fea681da
MK
156.TP
157.B IXOFF
158Enable XON/XOFF flow control on input.
159.TP
160.B IMAXBEL
161(not in POSIX) Ring bell when input queue is full.
162Linux does not implement this bit, and acts as if it is always set.
225c76e9
MK
163.TP
164.BR IUTF8 " (since Linux 2.6.4)"
165(not in POSIX) Input is UTF8;
166this allows character-erase to be correctly performed in cooked mode.
fea681da
MK
167.PP
168\fIc_oflag\fP flag constants defined in POSIX.1:
169.TP
170.B OPOST
171Enable implementation-defined output processing.
172.PP
68e1685c 173The remaining \fIc_oflag\fP flag constants are defined in POSIX.1-2001,
fea681da
MK
174unless marked otherwise.
175.TP
176.B OLCUC
177(not in POSIX) Map lowercase characters to uppercase on output.
178.TP
179.B ONLCR
180(XSI) Map NL to CR-NL on output.
181.TP
182.B OCRNL
183Map CR to NL on output.
184.TP
185.B ONOCR
186Don't output CR at column 0.
187.TP
188.B ONLRET
189Don't output CR.
190.TP
191.B OFILL
192Send fill characters for a delay, rather than using a timed delay.
193.TP
194.B OFDEL
195(not in POSIX) Fill character is ASCII DEL (0177).
28d88c17 196If unset, fill character is ASCII NUL ('\\0').
42b09930 197(Not implemented on Linux.)
fea681da
MK
198.TP
199.B NLDLY
200Newline delay mask. Values are \fBNL0\fP and \fBNL1\fP.
869ebe5b 201[requires _BSD_SOURCE or _SVID_SOURCE or _XOPEN_SOURCE]
fea681da
MK
202.TP
203.B CRDLY
204Carriage return delay mask.
205Values are \fBCR0\fP, \fBCR1\fP, \fBCR2\fP, or \fBCR3\fP.
869ebe5b 206[requires _BSD_SOURCE or _SVID_SOURCE or _XOPEN_SOURCE]
fea681da
MK
207.TP
208.B TABDLY
209Horizontal tab delay mask.
210Values are \fBTAB0\fP, \fBTAB1\fP, \fBTAB2\fP, \fBTAB3\fP (or \fBXTABS\fP).
211A value of TAB3, that is, XTABS, expands tabs to spaces
212(with tab stops every eight columns).
869ebe5b 213[requires _BSD_SOURCE or _SVID_SOURCE or _XOPEN_SOURCE]
fea681da
MK
214.TP
215.B BSDLY
216Backspace delay mask. Values are \fBBS0\fP or \fBBS1\fP.
217(Has never been implemented.)
869ebe5b 218[requires _BSD_SOURCE or _SVID_SOURCE or _XOPEN_SOURCE]
fea681da
MK
219.TP
220.B VTDLY
221Vertical tab delay mask. Values are \fBVT0\fP or \fBVT1\fP.
222.TP
223.B FFDLY
224Form feed delay mask. Values are \fBFF0\fP or \fBFF1\fP.
869ebe5b 225[requires _BSD_SOURCE or _SVID_SOURCE or _XOPEN_SOURCE]
fea681da
MK
226.PP
227\fIc_cflag\fP flag constants:
228.TP
229.B CBAUD
230(not in POSIX) Baud speed mask (4+1 bits).
869ebe5b 231[requires _BSD_SOURCE or _SVID_SOURCE]
fea681da
MK
232.TP
233.B CBAUDEX
234(not in POSIX) Extra baud speed mask (1 bit), included in CBAUD.
869ebe5b 235[requires _BSD_SOURCE or _SVID_SOURCE]
42b09930
MK
236.sp
237(POSIX says that the baud speed is stored in the
238.I termios
239structure without specifying where precisely, and provides
63aa9df0 240.BR cfgetispeed ()
fea681da 241and
63aa9df0 242.BR cfsetispeed ()
fea681da
MK
243for getting at it. Some systems use bits selected by CBAUD in
244.IR c_cflag ,
245other systems use separate fields, e.g.
246.I sg_ispeed
247and
248.IR sg_ospeed .)
249.TP
250.B CSIZE
251Character size mask.
252Values are \fBCS5\fP, \fBCS6\fP, \fBCS7\fP, or \fBCS8\fP.
253.TP
254.B CSTOPB
255Set two stop bits, rather than one.
256.TP
257.B CREAD
258Enable receiver.
259.TP
260.B PARENB
261Enable parity generation on output and parity checking for input.
262.TP
263.B PARODD
19ab0376
MK
264If set, then parity for input and output is odd;
265otherwise even parity is used.
fea681da
MK
266.TP
267.B HUPCL
268Lower modem control lines after last process closes the device (hang up).
269.TP
270.B CLOCAL
271Ignore modem control lines.
272.TP
273.B LOBLK
274(not in POSIX) Block output from a noncurrent shell layer.
42b09930 275For use by \fBshl\fP (shell layers). (Not implemented on Linux.)
fea681da
MK
276.TP
277.B CIBAUD
4a837837
MK
278(not in POSIX) Mask for input speeds.
279The values for the CIBAUD bits are
fea681da 280the same as the values for the CBAUD bits, shifted left IBSHIFT bits.
869ebe5b 281[requires _BSD_SOURCE or _SVID_SOURCE]
42b09930 282(Not implemented on Linux.)
fea681da 283.TP
adab6032 284.B CMSPAR
ad715af9 285(not in POSIX)
4a837837
MK
286Use "stick" (mark/space) parity (supported on certain serial
287devices): if
adab6032
MK
288.B PARODD
289is set, the parity bit is always 1; if
19ab0376 290.B PARODD
adab6032 291is not set, then the parity bit is always 0).
ad715af9 292[requires _BSD_SOURCE or _SVID_SOURCE]
adab6032 293.TP
fea681da
MK
294.B CRTSCTS
295(not in POSIX) Enable RTS/CTS (hardware) flow control.
869ebe5b 296[requires _BSD_SOURCE or _SVID_SOURCE]
fea681da
MK
297.PP
298\fIc_lflag\fP flag constants:
299.TP
300.B ISIG
301When any of the characters INTR, QUIT, SUSP, or DSUSP are received,
302generate the corresponding signal.
303.TP
304.B ICANON
19ab0376 305Enable canonical mode (described below).
fea681da
MK
306.TP
307.B XCASE
308(not in POSIX; not supported under Linux)
309If \fBICANON\fP is also set, terminal is uppercase only.
310Input is converted to lowercase, except for characters preceded by \\.
311On output, uppercase characters are preceded by \\ and lowercase
312characters are converted to uppercase.
869ebe5b
MK
313.\" [requires _BSD_SOURCE or _SVID_SOURCE or _XOPEN_SOURCE]
314.\" glibc is probably now wrong to allow _XOPEN_SOURCE to expose XCASE.
fea681da
MK
315.TP
316.B ECHO
317Echo input characters.
318.TP
319.B ECHOE
320If \fBICANON\fP is also set, the ERASE character erases the preceding
321input character, and WERASE erases the preceding word.
322.TP
323.B ECHOK
324If \fBICANON\fP is also set, the KILL character erases the current line.
325.TP
326.B ECHONL
327If \fBICANON\fP is also set, echo the NL character even if ECHO is not set.
328.TP
329.B ECHOCTL
330(not in POSIX) If \fBECHO\fP is also set, ASCII control signals other than
331TAB, NL, START, and STOP are echoed as ^X, where X is the character with
332ASCII code 0x40 greater than the control signal. For example, character
3330x08 (BS) is echoed as ^H.
869ebe5b 334[requires _BSD_SOURCE or _SVID_SOURCE]
fea681da
MK
335.TP
336.B ECHOPRT
337(not in POSIX) If \fBICANON\fP and \fBIECHO\fP are also set, characters
338are printed as they are being erased.
869ebe5b 339[requires _BSD_SOURCE or _SVID_SOURCE]
fea681da
MK
340.TP
341.B ECHOKE
342(not in POSIX) If \fBICANON\fP is also set, KILL is echoed by erasing
343each character on the line, as specified by \fBECHOE\fP and \fBECHOPRT\fP.
869ebe5b 344[requires _BSD_SOURCE or _SVID_SOURCE]
fea681da
MK
345.TP
346.B DEFECHO
347(not in POSIX) Echo only when a process is reading.
42b09930 348(Not implemented on Linux.)
fea681da
MK
349.TP
350.B FLUSHO
351(not in POSIX; not supported under Linux)
352Output is being flushed. This flag is toggled by typing
353the DISCARD character.
869ebe5b 354[requires _BSD_SOURCE or _SVID_SOURCE]
fea681da
MK
355.TP
356.B NOFLSH
357Disable flushing the input and output queues when generating the SIGINT,
358SIGQUIT and SIGSUSP signals.
359.\" Stevens lets SIGSUSP only flush the input queue
360.TP
361.B TOSTOP
362Send the SIGTTOU signal to the process group of a background process
363which tries to write to its controlling terminal.
364.TP
365.B PENDIN
366(not in POSIX; not supported under Linux)
367All characters in the input queue are reprinted when
368the next character is read. (\fBbash\fP handles typeahead this way.)
869ebe5b 369[requires _BSD_SOURCE or _SVID_SOURCE]
fea681da
MK
370.TP
371.B IEXTEN
372Enable implementation-defined input processing.
373This flag, as well as \fBICANON\fP must be enabled for the
374special characters EOL2, LNEXT, REPRINT, WERASE to be interpreted,
375and for the \fBIUCLC\fP flag to be effective.
376.PP
377The \fIc_cc\fP array defines the special control characters.
378The symbolic indices (initial values) and meaning are:
379.TP
380.B VINTR
381(003, ETX, Ctrl-C, or also 0177, DEL, rubout)
382Interrupt character. Send a SIGINT signal.
383Recognized when ISIG is set, and then not passed as input.
384.TP
385.B VQUIT
386(034, FS, Ctrl-\e)
387Quit character. Send SIGQUIT signal.
388Recognized when ISIG is set, and then not passed as input.
389.TP
390.B VERASE
391(0177, DEL, rubout, or 010, BS, Ctrl-H, or also #)
392Erase character. This erases the previous not-yet-erased character,
393but does not erase past EOF or beginning-of-line.
394Recognized when ICANON is set, and then not passed as input.
395.TP
396.B VKILL
397(025, NAK, Ctrl-U, or Ctrl-X, or also @)
19ab0376
MK
398Kill character.
399This erases the input since the last EOF or beginning-of-line.
fea681da
MK
400Recognized when ICANON is set, and then not passed as input.
401.TP
402.B VEOF
403(004, EOT, Ctrl-D)
404End-of-file character.
405More precisely: this character causes the pending tty buffer to be sent
406to the waiting user program without waiting for end-of-line.
63aa9df0 407If it is the first character of the line, the \fIread\fP() in the
fea681da
MK
408user program returns 0, which signifies end-of-file.
409Recognized when ICANON is set, and then not passed as input.
410.TP
411.B VMIN
412Minimum number of characters for non-canonical read.
413.TP
414.B VEOL
415(0, NUL)
416Additional end-of-line character.
417Recognized when ICANON is set.
418.TP
419.B VTIME
420Timeout in deciseconds for non-canonical read.
421.TP
422.B VEOL2
423(not in POSIX; 0, NUL)
424Yet another end-of-line character.
425Recognized when ICANON is set.
426.TP
427.B VSWTCH
428(not in POSIX; not supported under Linux; 0, NUL)
429Switch character. (Used by \fBshl\fP only.)
430.TP
431.B VSTART
432(021, DC1, Ctrl-Q)
433Start character. Restarts output stopped by the Stop character.
434Recognized when IXON is set, and then not passed as input.
435.TP
436.B VSTOP
437(023, DC3, Ctrl-S)
438Stop character. Stop output until Start character typed.
439Recognized when IXON is set, and then not passed as input.
440.TP
441.B VSUSP
442(032, SUB, Ctrl-Z)
443Suspend character. Send SIGTSTP signal.
444Recognized when ISIG is set, and then not passed as input.
445.TP
446.B VDSUSP
447(not in POSIX; not supported under Linux; 031, EM, Ctrl-Y)
448Delayed suspend character:
449send SIGTSTP signal when the character is read by the user program.
450Recognized when IEXTEN and ISIG are set, and the system supports
451job control, and then not passed as input.
452.TP
453.B VLNEXT
454(not in POSIX; 026, SYN, Ctrl-V)
455Literal next. Quotes the next input character, depriving it of
456a possible special meaning.
457Recognized when IEXTEN is set, and then not passed as input.
458.TP
459.B VWERASE
460(not in POSIX; 027, ETB, Ctrl-W)
461Word erase.
462Recognized when ICANON and IEXTEN are set, and then not passed as input.
463.TP
464.B VREPRINT
465(not in POSIX; 022, DC2, Ctrl-R)
466Reprint unread characters.
467Recognized when ICANON and IEXTEN are set, and then not passed as input.
468.TP
469.B VDISCARD
470(not in POSIX; not supported under Linux; 017, SI, Ctrl-O)
471Toggle: start/stop discarding pending output.
472Recognized when IEXTEN is set, and then not passed as input.
473.TP
474.B VSTATUS
475(not in POSIX; not supported under Linux;
476status request: 024, DC4, Ctrl-T).
477.LP
478These symbolic subscript values are all different, except that
479VTIME, VMIN may have the same value as VEOL, VEOF, respectively.
42b09930
MK
480In non-canonical mode the special character meaning is replaced
481by the timeout meaning.
19ab0376
MK
482For an explanation of VMIN and VTIME, see the description of
483non-canonical mode below.
87d1fd87 484.SS "Retrieving and changing terminal settings"
fea681da 485.PP
63aa9df0 486.BR tcgetattr ()
fea681da 487gets the parameters associated with the object referred by \fIfd\fP and
869ebe5b 488stores them in the \fItermios\fP structure referenced by
fea681da
MK
489\fItermios_p\fP. This function may be invoked from a background process;
490however, the terminal attributes may be subsequently changed by a
491foreground process.
492.LP
63aa9df0 493.BR tcsetattr ()
fea681da
MK
494sets the parameters associated with the terminal (unless support is
495required from the underlying hardware that is not available) from the
869ebe5b 496\fItermios\fP structure referred to by \fItermios_p\fP.
fea681da
MK
497\fIoptional_actions\fP specifies when the changes take effect:
498.IP \fBTCSANOW\fP
499the change occurs immediately.
500.IP \fBTCSADRAIN\fP
501the change occurs after all output written to
502.I fd
503has been transmitted. This function should be used when changing
504parameters that affect output.
505.IP \fBTCSAFLUSH\fP
506the change occurs after all output written to the object referred by
507.I fd
508has been transmitted, and all input that has been received but not read
509will be discarded before the change is made.
19ab0376
MK
510.SS "Canonical and non-canonical mode"
511The setting of the
512.B ICANON
513canon flag in
514.I c_lflag
515determines whether the terminal is operating in canonical mode
516.RB ( ICANON
517set) or
518non-canonical mode
519.RB ( ICANON
520unset).
521By default,
522.B ICANON
523set.
524
525In canonical mode:
526.IP * 2
527Input is made available line by line.
528An input line is available when one of the line delimiters
529is typed (NL, EOL, EOL2; or EOF at the start of line).
530Except in the case of EOF, the line delimiter is included
531in the buffer returned by
532.BR read (2).
533.IP * 2
534Line editing is enabled (ERASE, KILL;
535and if the
536.B IEXTEN
537flag is set: WERASE, REPRINT, LNEXT).
538A
539.BR read ()
540returns at most one line of input; if the
541.BR read ()
542requested fewer bytes than are available in the current line of input,
543then only as many bytes as requested are read,
544and the remaining characters will be available for a future
545.BR read ().
546.PP
547In non-canonical mode input is available immediately (without
548the user having to type a line-delimiter character),
549and line editing is disabled.
550The settings of MIN
551.RI ( c_cc[VMIN] )
552and
553.RI ( c_cc[VTIME] )
554determine the circumstances in which a
555.BR read (2)
556completes; there are four distinct cases:
557.IP * 2
558MIN == 0; TIME == 0:
559If data is available,
560.BR read ()
561returns immediately, with the lesser of the number of bytes
562available, or the number of bytes requested.
563If no data is available,
564.BR read ()
565returns 0.
566.IP * 2
567MIN > 0; TIME == 0:
568.BR read ()
569blocks until the lesser of MIN bytes or the number of bytes requested
570are available, and returns the lesser of these two values.
571.IP * 2
572MIN == 0; TIME > 0:
573TIME specifies the limit for a timer in tenths of a second.
574The timer is started when
575.BR read ()
576is called.
577.BR read ()
578returns either when at least one byte of data is available,
579or when the timer expires.
580If the timer expires without any input becoming available,
581.BR read ()
582returns 0.
583.IP * 2
584MIN > 0; TIME > 0:
585TIME specifies the limit for a timer in tenths of a second.
586Once an initial byte of input becomes available,
587the timer is restarted after each further byte is received.
588.BR read ()
589returns either when the lesser of the number of bytes requested or
590MIN byte have been read,
591or when the inter-byte timeout expires.
592Because the timer is only started after the initial byte
593becomes available, at least one byte will be read.
594.SS "Raw mode"
595.LP
596\fBcfmakeraw\fP() sets the terminal to something like the
1954b6a9 597"raw" mode of the old Version 7 terminal driver:
19ab0376
MK
598input is available character by character,
599echoing is disabled, and all special processing of
600terminal input and output characters is disabled.
601The terminal attributes are set as follows:
602.nf
603
604 termios_p->c_iflag &= ~(IGNBRK | BRKINT | PARMRK | ISTRIP
605 | INLCR | IGNCR | ICRNL | IXON);
606 termios_p->c_oflag &= ~OPOST;
607 termios_p->c_lflag &= ~(ECHO | ECHONL | ICANON | ISIG | IEXTEN);
608 termios_p->c_cflag &= ~(CSIZE | PARENB);
609 termios_p->c_cflag |= CS8;
610.fi
87d1fd87 611.SS "Line control"
fea681da 612.LP
63aa9df0 613.BR tcsendbreak ()
fea681da
MK
614transmits a continuous stream of zero-valued bits for a specific
615duration, if the terminal is using asynchronous serial data
616transmission. If \fIduration\fP is zero, it transmits zero-valued bits
617for at least 0.25 seconds, and not more that 0.5 seconds. If
618\fIduration\fP is not zero, it sends zero-valued bits for some
619implementation-defined length of time.
620.LP
621If the terminal is not using asynchronous serial data transmission,
63aa9df0 622\fBtcsendbreak\fP() returns without taking any action.
fea681da 623.LP
63aa9df0 624.BR tcdrain ()
fea681da
MK
625waits until all output written to the object referred to by
626.I fd
627has been transmitted.
628.LP
63aa9df0 629.BR tcflush ()
fea681da
MK
630discards data written to the object referred to by
631.I fd
632but not transmitted, or data received but not read, depending on the
633value of
634.IR queue_selector :
635.IP \fBTCIFLUSH\fP
636flushes data received but not read.
637.IP \fBTCOFLUSH\fP
638flushes data written but not transmitted.
639.IP \fBTCIOFLUSH\fP
640flushes both data received but not read, and data written but not
641transmitted.
642.LP
63aa9df0 643.BR tcflow ()
fea681da
MK
644suspends transmission or reception of data on the object referred to by
645.IR fd ,
646depending on the value of
647.IR action :
648.IP \fBTCOOFF\fP
649suspends output.
650.IP \fBTCOON\fP
651restarts suspended output.
652.IP \fBTCIOFF\fP
35478399
MK
653transmits a STOP character, which stops the terminal device from
654transmitting data to the system.
fea681da 655.IP \fBTCION\fP
35478399
MK
656transmits a START character, which starts the terminal device
657transmitting data to the system.
fea681da
MK
658.LP
659The default on open of a terminal file is that neither its input nor its
660output is suspended.
87d1fd87
MK
661.SS "Line speed"
662The baud rate functions are provided for getting and setting the values
663of the input and output baud rates in the \fItermios\fP structure. The
664new values do not take effect
665until \fBtcsetattr\fP() is successfully called.
666
667Setting the speed to \fBB0\fP instructs the modem to "hang up".
668The actual bit rate corresponding to \fBB38400\fP may be altered with
669\fBsetserial\fP(8).
670.LP
671The input and output baud rates are stored in the \fItermios\fP
672structure.
fea681da 673.LP
63aa9df0 674.BR cfgetospeed ()
869ebe5b 675returns the output baud rate stored in the \fItermios\fP structure
fea681da
MK
676pointed to by
677.IR termios_p .
678.LP
63aa9df0 679.BR cfsetospeed ()
869ebe5b 680sets the output baud rate stored in the \fItermios\fP structure pointed
fea681da
MK
681to by \fItermios_p\fP to \fIspeed\fP, which must be one of these constants:
682.nf
869ebe5b 683
fea681da
MK
684.ft B
685 B0
686 B50
687 B75
688 B110
689 B134
690 B150
691 B200
692 B300
693 B600
694 B1200
695 B1800
696 B2400
697 B4800
698 B9600
699 B19200
700 B38400
701 B57600
702 B115200
703 B230400
704.ft P
869ebe5b 705
fea681da
MK
706.fi
707The zero baud rate, \fBB0\fP,
708is used to terminate the connection. If B0
709is specified, the modem control lines shall no longer be asserted.
710Normally, this will disconnect the line. \fBCBAUDEX\fP is a mask
711for the speeds beyond those defined in POSIX.1 (57600 and above).
f59a3f19 712Thus, \fBB57600\fP & \fBCBAUDEX\fP is non-zero.
fea681da 713.LP
63aa9df0 714.BR cfgetispeed ()
869ebe5b 715returns the input baud rate stored in the \fItermios\fP structure.
fea681da 716.LP
63aa9df0 717.BR cfsetispeed ()
869ebe5b
MK
718sets the input baud rate stored in the \fItermios\fP structure to
719.IR speed ,
720which must be specified as one of the \fBBnnn\fP constants listed above for
721.BR cfsetospeed ().
fea681da
MK
722If the input baud rate is set to zero, the input baud rate will be
723equal to the output baud rate.
724.LP
63aa9df0 725.BR cfsetspeed ()
869ebe5b
MK
726is a 4.4BSD extension.
727It takes the same arguments as
728.BR cfsetispeed (),
729and sets both input and output speed.
fea681da
MK
730.SH "RETURN VALUE"
731.LP
63aa9df0 732.BR cfgetispeed ()
fea681da 733returns the input baud rate stored in the
869ebe5b 734\fItermios\fP
fea681da
MK
735structure.
736.LP
63aa9df0 737.BR cfgetospeed ()
869ebe5b 738returns the output baud rate stored in the \fItermios\fP structure.
fea681da
MK
739.LP
740All other functions return:
741.IP 0
742on success.
743.IP \-1
744on failure and set
745.I errno
746to indicate the error.
747.LP
748Note that
f87925c6 749.BR tcsetattr ()
fea681da
MK
750returns success if \fIany\fP of the requested changes could be
751successfully carried out. Therefore, when making multiple changes
752it may be necessary to follow this call with a further call to
f87925c6 753.BR tcgetattr ()
fea681da 754to check that all changes have been performed successfully.
fea681da
MK
755.SH NOTES
756Unix V7 and several later systems have a list of baud rates
757where after the fourteen values B0, ..., B9600 one finds the
758two constants EXTA, EXTB ("External A" and "External B").
759Many systems extend the list with much higher baud rates.
760.LP
e511ffb6 761The effect of a non-zero \fIduration\fP with \fBtcsendbreak\fP() varies.
fea681da
MK
762SunOS specifies a break of
763.IB duration * N
764seconds, where \fIN\fP is at least 0.25, and not more than 0.5.
765Linux, AIX, DU, Tru64 send a break of
766.I duration
767milliseconds.
768FreeBSD and NetBSD and HP-UX and MacOS ignore the value of
769.IR duration .
770Under Solaris and Unixware,
e511ffb6 771.BR tcsendbreak ()
f59a3f19 772with non-zero
fea681da
MK
773.I duration
774behaves like
e511ffb6 775.BR tcdrain ().
fea681da
MK
776.\" libc4 until 4.7.5, glibc for sysv: EINVAL for duration > 0.
777.\" libc4.7.6, libc5, glibc for unix: duration in ms.
778.\" glibc for bsd: duration in us
779.\" glibc for sunos4: ignore duration
780.SH "SEE ALSO"
781.BR stty (1),
fe62e3de
MK
782.BR console_ioctl (4),
783.BR tty_ioctl (4),
a8e7c990 784.BR feature_test_macros (7),
fea681da 785.BR setserial (8)