Blame man3/termios.3

Packit 7cfc04
.\" Copyright (c) 1993 Michael Haardt
Packit 7cfc04
.\" (michael@moria.de)
Packit 7cfc04
.\" Fri Apr  2 11:32:09 MET DST 1993
Packit 7cfc04
.\"
Packit 7cfc04
.\" %%%LICENSE_START(GPLv2+_DOC_FULL)
Packit 7cfc04
.\" This is free documentation; you can redistribute it and/or
Packit 7cfc04
.\" modify it under the terms of the GNU General Public License as
Packit 7cfc04
.\" published by the Free Software Foundation; either version 2 of
Packit 7cfc04
.\" the License, or (at your option) any later version.
Packit 7cfc04
.\"
Packit 7cfc04
.\" The GNU General Public License's references to "object code"
Packit 7cfc04
.\" and "executables" are to be interpreted as the output of any
Packit 7cfc04
.\" document formatting or typesetting system, including
Packit 7cfc04
.\" intermediate and printed output.
Packit 7cfc04
.\"
Packit 7cfc04
.\" This manual is distributed in the hope that it will be useful,
Packit 7cfc04
.\" but WITHOUT ANY WARRANTY; without even the implied warranty of
Packit 7cfc04
.\" MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
Packit 7cfc04
.\" GNU General Public License for more details.
Packit 7cfc04
.\"
Packit 7cfc04
.\" You should have received a copy of the GNU General Public
Packit 7cfc04
.\" License along with this manual; if not, see
Packit 7cfc04
.\" <http://www.gnu.org/licenses/>.
Packit 7cfc04
.\" %%%LICENSE_END
Packit 7cfc04
.\"
Packit 7cfc04
.\" Modified 1993-07-24 by Rik Faith <faith@cs.unc.edu>
Packit 7cfc04
.\" Modified 1995-02-25 by Jim Van Zandt <jrv@vanzandt.mv.com>
Packit 7cfc04
.\" Modified 1995-09-02 by Jim Van Zandt <jrv@vanzandt.mv.com>
Packit 7cfc04
.\" moved to man3, aeb, 950919
Packit 7cfc04
.\" Modified 2001-09-22 by Michael Kerrisk <mtk.manpages@gmail.com>
Packit 7cfc04
.\" Modified 2001-12-17, aeb
Packit 7cfc04
.\" Modified 2004-10-31, aeb
Packit 7cfc04
.\" 2006-12-28, mtk:
Packit 7cfc04
.\"     Added .SS headers to give some structure to this page; and a
Packit 7cfc04
.\"     small amount of reordering.
Packit 7cfc04
.\"     Added a section on canonical and noncanonical mode.
Packit 7cfc04
.\"     Enhanced the discussion of "raw" mode for cfmakeraw().
Packit 7cfc04
.\"     Document CMSPAR.
Packit 7cfc04
.\"
Packit 7cfc04
.TH TERMIOS 3 2017-09-15 "Linux" "Linux Programmer's Manual"
Packit 7cfc04
.SH NAME
Packit 7cfc04
termios, tcgetattr, tcsetattr, tcsendbreak, tcdrain, tcflush, tcflow,
Packit 7cfc04
cfmakeraw, cfgetospeed, cfgetispeed, cfsetispeed, cfsetospeed, cfsetspeed \-
Packit 7cfc04
get and set terminal attributes, line control, get and set baud rate
Packit 7cfc04
.SH SYNOPSIS
Packit 7cfc04
.nf
Packit 7cfc04
.B #include <termios.h>
Packit 7cfc04
.B #include <unistd.h>
Packit 7cfc04
.PP
Packit 7cfc04
.BI "int tcgetattr(int " fd ", struct termios *" termios_p );
Packit 7cfc04
.PP
Packit 7cfc04
.BI "int tcsetattr(int " fd ", int " optional_actions ,
Packit 7cfc04
.BI "              const struct termios *" termios_p );
Packit 7cfc04
.PP
Packit 7cfc04
.BI "int tcsendbreak(int " fd ", int " duration );
Packit 7cfc04
.PP
Packit 7cfc04
.BI "int tcdrain(int " fd );
Packit 7cfc04
.PP
Packit 7cfc04
.BI "int tcflush(int " fd ", int " queue_selector );
Packit 7cfc04
.PP
Packit 7cfc04
.BI "int tcflow(int " fd ", int " action );
Packit 7cfc04
.PP
Packit 7cfc04
.BI "void cfmakeraw(struct termios *" termios_p );
Packit 7cfc04
.PP
Packit 7cfc04
.BI "speed_t cfgetispeed(const struct termios *" termios_p );
Packit 7cfc04
.PP
Packit 7cfc04
.BI "speed_t cfgetospeed(const struct termios *" termios_p );
Packit 7cfc04
.PP
Packit 7cfc04
.BI "int cfsetispeed(struct termios *" termios_p ", speed_t " speed );
Packit 7cfc04
.PP
Packit 7cfc04
.BI "int cfsetospeed(struct termios *" termios_p ", speed_t " speed );
Packit 7cfc04
.PP
Packit 7cfc04
.BI "int cfsetspeed(struct termios *" termios_p ", speed_t " speed );
Packit 7cfc04
.fi
Packit 7cfc04
.PP
Packit 7cfc04
.in -4n
Packit 7cfc04
Feature Test Macro Requirements for glibc (see
Packit 7cfc04
.BR feature_test_macros (7)):
Packit 7cfc04
.in
Packit 7cfc04
.PP
Packit 7cfc04
.BR cfsetspeed (),
Packit 7cfc04
.BR cfmakeraw ():
Packit 7cfc04
    Since glibc 2.19:
Packit 7cfc04
        _DEFAULT_SOURCE
Packit 7cfc04
    Glibc 2.19 and earlier:
Packit 7cfc04
        _BSD_SOURCE
Packit 7cfc04
.SH DESCRIPTION
Packit 7cfc04
The termios functions describe a general terminal interface that is
Packit 7cfc04
provided to control asynchronous communications ports.
Packit 7cfc04
.SS The termios structure
Packit 7cfc04
.PP
Packit 7cfc04
Many of the functions described here have a \fItermios_p\fP argument
Packit 7cfc04
that is a pointer to a \fItermios\fP structure.
Packit 7cfc04
This structure contains at least the following members:
Packit 7cfc04
.PP
Packit 7cfc04
.in +4n
Packit 7cfc04
.EX
Packit 7cfc04
tcflag_t c_iflag;      /* input modes */
Packit 7cfc04
tcflag_t c_oflag;      /* output modes */
Packit 7cfc04
tcflag_t c_cflag;      /* control modes */
Packit 7cfc04
tcflag_t c_lflag;      /* local modes */
Packit 7cfc04
cc_t     c_cc[NCCS];   /* special characters */
Packit 7cfc04
.EE
Packit 7cfc04
.in
Packit 7cfc04
.PP
Packit 7cfc04
The values that may be assigned to these fields are described below.
Packit 7cfc04
In the case of the first four bit-mask fields,
Packit 7cfc04
the definitions of some of the associated flags that may be set are
Packit 7cfc04
exposed only if a specific feature test macro (see
Packit 7cfc04
.BR feature_test_macros (7))
Packit 7cfc04
is defined, as noted in brackets ("[]").
Packit 7cfc04
.PP
Packit 7cfc04
In the descriptions below, "not in POSIX" means that the
Packit 7cfc04
value is not specified in POSIX.1-2001,
Packit 7cfc04
and "XSI" means that the value is specified in POSIX.1-2001
Packit 7cfc04
as part of the XSI extension.
Packit 7cfc04
.PP
Packit 7cfc04
\fIc_iflag\fP flag constants:
Packit 7cfc04
.TP
Packit 7cfc04
.B IGNBRK
Packit 7cfc04
Ignore BREAK condition on input.
Packit 7cfc04
.TP
Packit 7cfc04
.B BRKINT
Packit 7cfc04
If \fBIGNBRK\fP is set, a BREAK is ignored.
Packit 7cfc04
If it is not set
Packit 7cfc04
but \fBBRKINT\fP is set, then a BREAK causes the input and output
Packit 7cfc04
queues to be flushed, and if the terminal is the controlling
Packit 7cfc04
terminal of a foreground process group, it will cause a
Packit 7cfc04
\fBSIGINT\fP to be sent to this foreground process group.
Packit 7cfc04
When neither \fBIGNBRK\fP nor \fBBRKINT\fP are set, a BREAK
Packit 7cfc04
reads as a null byte (\(aq\\0\(aq), except when \fBPARMRK\fP is set,
Packit 7cfc04
in which case it reads as the sequence \\377 \\0 \\0.
Packit 7cfc04
.TP
Packit 7cfc04
.B IGNPAR
Packit 7cfc04
Ignore framing errors and parity errors.
Packit 7cfc04
.TP
Packit 7cfc04
.B PARMRK
Packit 7cfc04
If this bit is set, input bytes with parity or framing errors are
Packit 7cfc04
marked when passed to the program.
Packit 7cfc04
This bit is meaningful only when
Packit 7cfc04
\fBINPCK\fP is set and \fBIGNPAR\fP is not set.
Packit 7cfc04
The way erroneous bytes are marked is with two preceding bytes,
Packit 7cfc04
\\377 and \\0.
Packit 7cfc04
Thus, the program actually reads three bytes for one
Packit 7cfc04
erroneous byte received from the terminal.
Packit 7cfc04
If a valid byte has the value \\377,
Packit 7cfc04
and \fBISTRIP\fP (see below) is not set,
Packit 7cfc04
the program might confuse it with the prefix that marks a
Packit 7cfc04
parity error.
Packit 7cfc04
Therefore, a valid byte \\377 is passed to the program as two
Packit 7cfc04
bytes, \\377 \\377, in this case.
Packit 7cfc04
.IP
Packit 7cfc04
If neither \fBIGNPAR\fP nor \fBPARMRK\fP
Packit 7cfc04
is set, read a character with a parity error or framing error
Packit 7cfc04
as \\0.
Packit 7cfc04
.TP
Packit 7cfc04
.B INPCK
Packit 7cfc04
Enable input parity checking.
Packit 7cfc04
.TP
Packit 7cfc04
.B ISTRIP
Packit 7cfc04
Strip off eighth bit.
Packit 7cfc04
.TP
Packit 7cfc04
.B INLCR
Packit 7cfc04
Translate NL to CR on input.
Packit 7cfc04
.TP
Packit 7cfc04
.B IGNCR
Packit 7cfc04
Ignore carriage return on input.
Packit 7cfc04
.TP
Packit 7cfc04
.B ICRNL
Packit 7cfc04
Translate carriage return to newline on input (unless \fBIGNCR\fP is set).
Packit 7cfc04
.TP
Packit 7cfc04
.B IUCLC
Packit 7cfc04
(not in POSIX) Map uppercase characters to lowercase on input.
Packit 7cfc04
.TP
Packit 7cfc04
.B IXON
Packit 7cfc04
Enable XON/XOFF flow control on output.
Packit 7cfc04
.TP
Packit 7cfc04
.B IXANY
Packit 7cfc04
(XSI) Typing any character will restart stopped output.
Packit 7cfc04
(The default is to allow just the START character to restart output.)
Packit 7cfc04
.TP
Packit 7cfc04
.B IXOFF
Packit 7cfc04
Enable XON/XOFF flow control on input.
Packit 7cfc04
.TP
Packit 7cfc04
.B IMAXBEL
Packit 7cfc04
(not in POSIX) Ring bell when input queue is full.
Packit 7cfc04
Linux does not implement this bit, and acts as if it is always set.
Packit 7cfc04
.TP
Packit 7cfc04
.BR IUTF8 " (since Linux 2.6.4)"
Packit 7cfc04
(not in POSIX) Input is UTF8;
Packit 7cfc04
this allows character-erase to be correctly performed in cooked mode.
Packit 7cfc04
.PP
Packit 7cfc04
.I c_oflag
Packit 7cfc04
flag constants:
Packit 7cfc04
.TP
Packit 7cfc04
.B OPOST
Packit 7cfc04
Enable implementation-defined output processing.
Packit 7cfc04
.TP
Packit 7cfc04
.B OLCUC
Packit 7cfc04
(not in POSIX) Map lowercase characters to uppercase on output.
Packit 7cfc04
.TP
Packit 7cfc04
.B ONLCR
Packit 7cfc04
(XSI) Map NL to CR-NL on output.
Packit 7cfc04
.TP
Packit 7cfc04
.B OCRNL
Packit 7cfc04
Map CR to NL on output.
Packit 7cfc04
.TP
Packit 7cfc04
.B ONOCR
Packit 7cfc04
Don't output CR at column 0.
Packit 7cfc04
.TP
Packit 7cfc04
.B ONLRET
Packit 7cfc04
Don't output CR.
Packit 7cfc04
.TP
Packit 7cfc04
.B OFILL
Packit 7cfc04
Send fill characters for a delay, rather than using a timed delay.
Packit 7cfc04
.TP
Packit 7cfc04
.B OFDEL
Packit 7cfc04
Fill character is ASCII DEL (0177).
Packit 7cfc04
If unset, fill character is ASCII NUL (\(aq\\0\(aq).
Packit 7cfc04
(Not implemented on Linux.)
Packit 7cfc04
.TP
Packit 7cfc04
.B NLDLY
Packit 7cfc04
Newline delay mask.
Packit 7cfc04
Values are \fBNL0\fP and \fBNL1\fP.
Packit 7cfc04
[requires
Packit 7cfc04
.B _BSD_SOURCE
Packit 7cfc04
or
Packit 7cfc04
.B _SVID_SOURCE
Packit 7cfc04
or
Packit 7cfc04
.BR _XOPEN_SOURCE ]
Packit 7cfc04
.TP
Packit 7cfc04
.B CRDLY
Packit 7cfc04
Carriage return delay mask.
Packit 7cfc04
Values are \fBCR0\fP, \fBCR1\fP, \fBCR2\fP, or \fBCR3\fP.
Packit 7cfc04
[requires
Packit 7cfc04
.B _BSD_SOURCE
Packit 7cfc04
or
Packit 7cfc04
.B _SVID_SOURCE
Packit 7cfc04
or
Packit 7cfc04
.BR _XOPEN_SOURCE ]
Packit 7cfc04
.TP
Packit 7cfc04
.B TABDLY
Packit 7cfc04
Horizontal tab delay mask.
Packit 7cfc04
Values are \fBTAB0\fP, \fBTAB1\fP, \fBTAB2\fP, \fBTAB3\fP (or \fBXTABS\fP).
Packit 7cfc04
A value of TAB3, that is, XTABS, expands tabs to spaces
Packit 7cfc04
(with tab stops every eight columns).
Packit 7cfc04
[requires
Packit 7cfc04
.B _BSD_SOURCE
Packit 7cfc04
or
Packit 7cfc04
.B _SVID_SOURCE
Packit 7cfc04
or
Packit 7cfc04
.BR _XOPEN_SOURCE ]
Packit 7cfc04
.TP
Packit 7cfc04
.B BSDLY
Packit 7cfc04
Backspace delay mask.
Packit 7cfc04
Values are \fBBS0\fP or \fBBS1\fP.
Packit 7cfc04
(Has never been implemented.)
Packit 7cfc04
[requires
Packit 7cfc04
.B _BSD_SOURCE
Packit 7cfc04
or
Packit 7cfc04
.B _SVID_SOURCE
Packit 7cfc04
or
Packit 7cfc04
.BR _XOPEN_SOURCE ]
Packit 7cfc04
.TP
Packit 7cfc04
.B VTDLY
Packit 7cfc04
Vertical tab delay mask.
Packit 7cfc04
Values are \fBVT0\fP or \fBVT1\fP.
Packit 7cfc04
.TP
Packit 7cfc04
.B FFDLY
Packit 7cfc04
Form feed delay mask.
Packit 7cfc04
Values are \fBFF0\fP or \fBFF1\fP.
Packit 7cfc04
[requires
Packit 7cfc04
.B _BSD_SOURCE
Packit 7cfc04
or
Packit 7cfc04
.B _SVID_SOURCE
Packit 7cfc04
or
Packit 7cfc04
.BR _XOPEN_SOURCE ]
Packit 7cfc04
.PP
Packit 7cfc04
\fIc_cflag\fP flag constants:
Packit 7cfc04
.TP
Packit 7cfc04
.B CBAUD
Packit 7cfc04
(not in POSIX) Baud speed mask (4+1 bits).
Packit 7cfc04
[requires
Packit 7cfc04
.B _BSD_SOURCE
Packit 7cfc04
or
Packit 7cfc04
.BR _SVID_SOURCE ]
Packit 7cfc04
.TP
Packit 7cfc04
.B CBAUDEX
Packit 7cfc04
(not in POSIX) Extra baud speed mask (1 bit), included in
Packit 7cfc04
.BR CBAUD .
Packit 7cfc04
[requires
Packit 7cfc04
.B _BSD_SOURCE
Packit 7cfc04
or
Packit 7cfc04
.BR _SVID_SOURCE ]
Packit 7cfc04
.IP
Packit 7cfc04
(POSIX says that the baud speed is stored in the
Packit 7cfc04
.I termios
Packit 7cfc04
structure without specifying where precisely, and provides
Packit 7cfc04
.BR cfgetispeed ()
Packit 7cfc04
and
Packit 7cfc04
.BR cfsetispeed ()
Packit 7cfc04
for getting at it.
Packit 7cfc04
Some systems use bits selected by
Packit 7cfc04
.B CBAUD
Packit 7cfc04
in
Packit 7cfc04
.IR c_cflag ,
Packit 7cfc04
other systems use separate fields, for example,
Packit 7cfc04
.I sg_ispeed
Packit 7cfc04
and
Packit 7cfc04
.IR sg_ospeed .)
Packit 7cfc04
.TP
Packit 7cfc04
.B CSIZE
Packit 7cfc04
Character size mask.
Packit 7cfc04
Values are \fBCS5\fP, \fBCS6\fP, \fBCS7\fP, or \fBCS8\fP.
Packit 7cfc04
.TP
Packit 7cfc04
.B CSTOPB
Packit 7cfc04
Set two stop bits, rather than one.
Packit 7cfc04
.TP
Packit 7cfc04
.B CREAD
Packit 7cfc04
Enable receiver.
Packit 7cfc04
.TP
Packit 7cfc04
.B PARENB
Packit 7cfc04
Enable parity generation on output and parity checking for input.
Packit 7cfc04
.TP
Packit 7cfc04
.B PARODD
Packit 7cfc04
If set, then parity for input and output is odd;
Packit 7cfc04
otherwise even parity is used.
Packit 7cfc04
.TP
Packit 7cfc04
.B HUPCL
Packit 7cfc04
Lower modem control lines after last process closes the device (hang up).
Packit 7cfc04
.TP
Packit 7cfc04
.B CLOCAL
Packit 7cfc04
Ignore modem control lines.
Packit 7cfc04
.TP
Packit 7cfc04
.B LOBLK
Packit 7cfc04
(not in POSIX) Block output from a noncurrent shell layer.
Packit 7cfc04
For use by \fBshl\fP (shell layers).  (Not implemented on Linux.)
Packit 7cfc04
.TP
Packit 7cfc04
.B CIBAUD
Packit 7cfc04
(not in POSIX) Mask for input speeds.
Packit 7cfc04
The values for the
Packit 7cfc04
.B CIBAUD
Packit 7cfc04
bits are
Packit 7cfc04
the same as the values for the
Packit 7cfc04
.B CBAUD
Packit 7cfc04
bits, shifted left
Packit 7cfc04
.B IBSHIFT
Packit 7cfc04
bits.
Packit 7cfc04
[requires
Packit 7cfc04
.B _BSD_SOURCE
Packit 7cfc04
or
Packit 7cfc04
.BR _SVID_SOURCE ]
Packit 7cfc04
(Not implemented on Linux.)
Packit 7cfc04
.TP
Packit 7cfc04
.B CMSPAR
Packit 7cfc04
(not in POSIX)
Packit 7cfc04
Use "stick" (mark/space) parity (supported on certain serial
Packit 7cfc04
devices): if
Packit 7cfc04
.B PARODD
Packit 7cfc04
is set, the parity bit is always 1; if
Packit 7cfc04
.B PARODD
Packit 7cfc04
is not set, then the parity bit is always 0.
Packit 7cfc04
[requires
Packit 7cfc04
.B _BSD_SOURCE
Packit 7cfc04
or
Packit 7cfc04
.BR _SVID_SOURCE ]
Packit 7cfc04
.TP
Packit 7cfc04
.B CRTSCTS
Packit 7cfc04
(not in POSIX) Enable RTS/CTS (hardware) flow control.
Packit 7cfc04
[requires
Packit 7cfc04
.B _BSD_SOURCE
Packit 7cfc04
or
Packit 7cfc04
.BR _SVID_SOURCE ]
Packit 7cfc04
.PP
Packit 7cfc04
\fIc_lflag\fP flag constants:
Packit 7cfc04
.TP
Packit 7cfc04
.B ISIG
Packit 7cfc04
When any of the characters INTR, QUIT, SUSP, or DSUSP are received,
Packit 7cfc04
generate the corresponding signal.
Packit 7cfc04
.TP
Packit 7cfc04
.B ICANON
Packit 7cfc04
Enable canonical mode (described below).
Packit 7cfc04
.TP
Packit 7cfc04
.B XCASE
Packit 7cfc04
(not in POSIX; not supported under Linux)
Packit 7cfc04
If \fBICANON\fP is also set, terminal is uppercase only.
Packit 7cfc04
Input is converted to lowercase, except for characters preceded by \\.
Packit 7cfc04
On output, uppercase characters are preceded by \\ and lowercase
Packit 7cfc04
characters are converted to uppercase.
Packit 7cfc04
[requires
Packit 7cfc04
.B _BSD_SOURCE
Packit 7cfc04
or
Packit 7cfc04
.B _SVID_SOURCE
Packit 7cfc04
or
Packit 7cfc04
.BR _XOPEN_SOURCE ]
Packit 7cfc04
.\" glibc is probably now wrong to allow
Packit 7cfc04
.\" Define
Packit 7cfc04
.\" .B _XOPEN_SOURCE
Packit 7cfc04
.\" to expose
Packit 7cfc04
.\" .BR XCASE .
Packit 7cfc04
.TP
Packit 7cfc04
.B ECHO
Packit 7cfc04
Echo input characters.
Packit 7cfc04
.TP
Packit 7cfc04
.B ECHOE
Packit 7cfc04
If \fBICANON\fP is also set, the ERASE character erases the preceding
Packit 7cfc04
input character, and WERASE erases the preceding word.
Packit 7cfc04
.TP
Packit 7cfc04
.B ECHOK
Packit 7cfc04
If \fBICANON\fP is also set, the KILL character erases the current line.
Packit 7cfc04
.TP
Packit 7cfc04
.B ECHONL
Packit 7cfc04
If \fBICANON\fP is also set, echo the NL character even if ECHO is not set.
Packit 7cfc04
.TP
Packit 7cfc04
.B ECHOCTL
Packit 7cfc04
(not in POSIX) If \fBECHO\fP is also set,
Packit 7cfc04
terminal special characters other than
Packit 7cfc04
TAB, NL, START, and STOP are echoed as \fB^X\fP,
Packit 7cfc04
where X is the character with
Packit 7cfc04
ASCII code 0x40 greater than the special character.
Packit 7cfc04
For example, character
Packit 7cfc04
0x08 (BS) is echoed as \fB^H\fP.
Packit 7cfc04
[requires
Packit 7cfc04
.B _BSD_SOURCE
Packit 7cfc04
or
Packit 7cfc04
.BR _SVID_SOURCE ]
Packit 7cfc04
.TP
Packit 7cfc04
.B ECHOPRT
Packit 7cfc04
(not in POSIX) If \fBICANON\fP and \fBECHO\fP are also set, characters
Packit 7cfc04
are printed as they are being erased.
Packit 7cfc04
[requires
Packit 7cfc04
.B _BSD_SOURCE
Packit 7cfc04
or
Packit 7cfc04
.BR _SVID_SOURCE ]
Packit 7cfc04
.TP
Packit 7cfc04
.B ECHOKE
Packit 7cfc04
(not in POSIX) If \fBICANON\fP is also set, KILL is echoed by erasing
Packit 7cfc04
each character on the line, as specified by \fBECHOE\fP and \fBECHOPRT\fP.
Packit 7cfc04
[requires
Packit 7cfc04
.B _BSD_SOURCE
Packit 7cfc04
or
Packit 7cfc04
.BR _SVID_SOURCE ]
Packit 7cfc04
.TP
Packit 7cfc04
.B DEFECHO
Packit 7cfc04
(not in POSIX) Echo only when a process is reading.
Packit 7cfc04
(Not implemented on Linux.)
Packit 7cfc04
.TP
Packit 7cfc04
.B FLUSHO
Packit 7cfc04
(not in POSIX; not supported under Linux)
Packit 7cfc04
Output is being flushed.
Packit 7cfc04
This flag is toggled by typing
Packit 7cfc04
the DISCARD character.
Packit 7cfc04
[requires
Packit 7cfc04
.B _BSD_SOURCE
Packit 7cfc04
or
Packit 7cfc04
.BR _SVID_SOURCE ]
Packit 7cfc04
.TP
Packit 7cfc04
.B NOFLSH
Packit 7cfc04
Disable flushing the input and output queues when generating signals for the
Packit 7cfc04
INT, QUIT, and SUSP characters.
Packit 7cfc04
.\" Stevens lets SUSP only flush the input queue
Packit 7cfc04
.TP
Packit 7cfc04
.B TOSTOP
Packit 7cfc04
Send the
Packit 7cfc04
.B SIGTTOU
Packit 7cfc04
signal to the process group of a background process
Packit 7cfc04
which tries to write to its controlling terminal.
Packit 7cfc04
.TP
Packit 7cfc04
.B PENDIN
Packit 7cfc04
(not in POSIX; not supported under Linux)
Packit 7cfc04
All characters in the input queue are reprinted when
Packit 7cfc04
the next character is read.
Packit 7cfc04
.RB ( bash (1)
Packit 7cfc04
handles typeahead this way.)
Packit 7cfc04
[requires
Packit 7cfc04
.B _BSD_SOURCE
Packit 7cfc04
or
Packit 7cfc04
.BR _SVID_SOURCE ]
Packit 7cfc04
.TP
Packit 7cfc04
.B IEXTEN
Packit 7cfc04
Enable implementation-defined input processing.
Packit 7cfc04
This flag, as well as \fBICANON\fP must be enabled for the
Packit 7cfc04
special characters EOL2, LNEXT, REPRINT, WERASE to be interpreted,
Packit 7cfc04
and for the \fBIUCLC\fP flag to be effective.
Packit 7cfc04
.PP
Packit 7cfc04
The \fIc_cc\fP array defines the terminal special characters.
Packit 7cfc04
The symbolic indices (initial values) and meaning are:
Packit 7cfc04
.TP
Packit 7cfc04
.B VDISCARD
Packit 7cfc04
(not in POSIX; not supported under Linux; 017, SI, Ctrl-O)
Packit 7cfc04
Toggle: start/stop discarding pending output.
Packit 7cfc04
Recognized when
Packit 7cfc04
.B IEXTEN
Packit 7cfc04
is set, and then not passed as input.
Packit 7cfc04
.TP
Packit 7cfc04
.B VDSUSP
Packit 7cfc04
(not in POSIX; not supported under Linux; 031, EM, Ctrl-Y)
Packit 7cfc04
Delayed suspend character (DSUSP):
Packit 7cfc04
send
Packit 7cfc04
.B SIGTSTP
Packit 7cfc04
signal when the character is read by the user program.
Packit 7cfc04
Recognized when
Packit 7cfc04
.B IEXTEN
Packit 7cfc04
and
Packit 7cfc04
.B ISIG
Packit 7cfc04
are set, and the system supports
Packit 7cfc04
job control, and then not passed as input.
Packit 7cfc04
.TP
Packit 7cfc04
.B VEOF
Packit 7cfc04
(004, EOT, Ctrl-D)
Packit 7cfc04
End-of-file character (EOF).
Packit 7cfc04
More precisely: this character causes the pending tty buffer to be sent
Packit 7cfc04
to the waiting user program without waiting for end-of-line.
Packit 7cfc04
If it is the first character of the line, the
Packit 7cfc04
.BR read (2)
Packit 7cfc04
in the user program returns 0, which signifies end-of-file.
Packit 7cfc04
Recognized when
Packit 7cfc04
.B ICANON
Packit 7cfc04
is set, and then not passed as input.
Packit 7cfc04
.TP
Packit 7cfc04
.B VEOL
Packit 7cfc04
(0, NUL)
Packit 7cfc04
Additional end-of-line character (EOL).
Packit 7cfc04
Recognized when
Packit 7cfc04
.B ICANON
Packit 7cfc04
is set.
Packit 7cfc04
.TP
Packit 7cfc04
.B VEOL2
Packit 7cfc04
(not in POSIX; 0, NUL)
Packit 7cfc04
Yet another end-of-line character (EOL2).
Packit 7cfc04
Recognized when
Packit 7cfc04
.B ICANON
Packit 7cfc04
is set.
Packit 7cfc04
.TP
Packit 7cfc04
.B VERASE
Packit 7cfc04
(0177, DEL, rubout, or 010, BS, Ctrl-H, or also #)
Packit 7cfc04
Erase character (ERASE).
Packit 7cfc04
This erases the previous not-yet-erased character,
Packit 7cfc04
but does not erase past EOF or beginning-of-line.
Packit 7cfc04
Recognized when
Packit 7cfc04
.B ICANON
Packit 7cfc04
is set, and then not passed as input.
Packit 7cfc04
.TP
Packit 7cfc04
.B VINTR
Packit 7cfc04
(003, ETX, Ctrl-C, or also 0177, DEL, rubout)
Packit 7cfc04
Interrupt character (INTR).
Packit 7cfc04
Send a
Packit 7cfc04
.B SIGINT
Packit 7cfc04
signal.
Packit 7cfc04
Recognized when
Packit 7cfc04
.B ISIG
Packit 7cfc04
is set, and then not passed as input.
Packit 7cfc04
.TP
Packit 7cfc04
.B VKILL
Packit 7cfc04
(025, NAK, Ctrl-U, or Ctrl-X, or also @)
Packit 7cfc04
Kill character (KILL).
Packit 7cfc04
This erases the input since the last EOF or beginning-of-line.
Packit 7cfc04
Recognized when
Packit 7cfc04
.B ICANON
Packit 7cfc04
is set, and then not passed as input.
Packit 7cfc04
.TP
Packit 7cfc04
.B VLNEXT
Packit 7cfc04
(not in POSIX; 026, SYN, Ctrl-V)
Packit 7cfc04
Literal next (LNEXT).
Packit 7cfc04
Quotes the next input character, depriving it of
Packit 7cfc04
a possible special meaning.
Packit 7cfc04
Recognized when
Packit 7cfc04
.B IEXTEN
Packit 7cfc04
is set, and then not passed as input.
Packit 7cfc04
.TP
Packit 7cfc04
.B VMIN
Packit 7cfc04
Minimum number of characters for noncanonical read (MIN).
Packit 7cfc04
.TP
Packit 7cfc04
.B VQUIT
Packit 7cfc04
(034, FS, Ctrl-\e)
Packit 7cfc04
Quit character (QUIT).
Packit 7cfc04
Send
Packit 7cfc04
.B SIGQUIT
Packit 7cfc04
signal.
Packit 7cfc04
Recognized when
Packit 7cfc04
.B ISIG
Packit 7cfc04
is set, and then not passed as input.
Packit 7cfc04
.TP
Packit 7cfc04
.B VREPRINT
Packit 7cfc04
(not in POSIX; 022, DC2, Ctrl-R)
Packit 7cfc04
Reprint unread characters (REPRINT).
Packit 7cfc04
Recognized when
Packit 7cfc04
.B ICANON
Packit 7cfc04
and
Packit 7cfc04
.B IEXTEN
Packit 7cfc04
are set, and then not passed as input.
Packit 7cfc04
.TP
Packit 7cfc04
.B VSTART
Packit 7cfc04
(021, DC1, Ctrl-Q)
Packit 7cfc04
Start character (START).
Packit 7cfc04
Restarts output stopped by the Stop character.
Packit 7cfc04
Recognized when
Packit 7cfc04
.B IXON
Packit 7cfc04
is set, and then not passed as input.
Packit 7cfc04
.TP
Packit 7cfc04
.B VSTATUS
Packit 7cfc04
(not in POSIX; not supported under Linux;
Packit 7cfc04
status request: 024, DC4, Ctrl-T).
Packit 7cfc04
Status character (STATUS).
Packit 7cfc04
Display status information at terminal,
Packit 7cfc04
including state of foreground process and amount of CPU time it has consumed.
Packit 7cfc04
Also sends a
Packit 7cfc04
.BR SIGINFO
Packit 7cfc04
signal (not supported on Linux) to the foreground process group.
Packit 7cfc04
.TP
Packit 7cfc04
.B VSTOP
Packit 7cfc04
(023, DC3, Ctrl-S)
Packit 7cfc04
Stop character (STOP).
Packit 7cfc04
Stop output until Start character typed.
Packit 7cfc04
Recognized when
Packit 7cfc04
.B IXON
Packit 7cfc04
is set, and then not passed as input.
Packit 7cfc04
.TP
Packit 7cfc04
.B VSUSP
Packit 7cfc04
(032, SUB, Ctrl-Z)
Packit 7cfc04
Suspend character (SUSP).
Packit 7cfc04
Send
Packit 7cfc04
.B SIGTSTP
Packit 7cfc04
signal.
Packit 7cfc04
Recognized when
Packit 7cfc04
.B ISIG
Packit 7cfc04
is set, and then not passed as input.
Packit 7cfc04
.TP
Packit 7cfc04
.B VSWTCH
Packit 7cfc04
(not in POSIX; not supported under Linux; 0, NUL)
Packit 7cfc04
Switch character (SWTCH).
Packit 7cfc04
Used in System V to switch shells in
Packit 7cfc04
.IR "shell layers" ,
Packit 7cfc04
a predecessor to shell job control.
Packit 7cfc04
.TP
Packit 7cfc04
.B VTIME
Packit 7cfc04
Timeout in deciseconds for noncanonical read (TIME).
Packit 7cfc04
.TP
Packit 7cfc04
.B VWERASE
Packit 7cfc04
(not in POSIX; 027, ETB, Ctrl-W)
Packit 7cfc04
Word erase (WERASE).
Packit 7cfc04
Recognized when
Packit 7cfc04
.B ICANON
Packit 7cfc04
and
Packit 7cfc04
.B IEXTEN
Packit 7cfc04
are set, and then not passed as input.
Packit 7cfc04
.PP
Packit 7cfc04
An individual terminal special character can be disabled by setting
Packit 7cfc04
the value of the corresponding
Packit 7cfc04
.I c_cc
Packit 7cfc04
element to
Packit 7cfc04
.BR _POSIX_VDISABLE .
Packit 7cfc04
.PP
Packit 7cfc04
The above symbolic subscript values are all different, except that
Packit 7cfc04
.BR VTIME ,
Packit 7cfc04
.B VMIN
Packit 7cfc04
may have the same value as
Packit 7cfc04
.BR VEOL ,
Packit 7cfc04
.BR VEOF ,
Packit 7cfc04
respectively.
Packit 7cfc04
In noncanonical mode the special character meaning is replaced
Packit 7cfc04
by the timeout meaning.
Packit 7cfc04
For an explanation of
Packit 7cfc04
.B VMIN
Packit 7cfc04
and
Packit 7cfc04
.BR VTIME ,
Packit 7cfc04
see the description of
Packit 7cfc04
noncanonical mode below.
Packit 7cfc04
.SS Retrieving and changing terminal settings
Packit 7cfc04
.PP
Packit 7cfc04
.BR tcgetattr ()
Packit 7cfc04
gets the parameters associated with the object referred by \fIfd\fP and
Packit 7cfc04
stores them in the \fItermios\fP structure referenced by
Packit 7cfc04
\fItermios_p\fP.
Packit 7cfc04
This function may be invoked from a background process;
Packit 7cfc04
however, the terminal attributes may be subsequently changed by a
Packit 7cfc04
foreground process.
Packit 7cfc04
.PP
Packit 7cfc04
.BR tcsetattr ()
Packit 7cfc04
sets the parameters associated with the terminal (unless support is
Packit 7cfc04
required from the underlying hardware that is not available) from the
Packit 7cfc04
\fItermios\fP structure referred to by \fItermios_p\fP.
Packit 7cfc04
\fIoptional_actions\fP specifies when the changes take effect:
Packit 7cfc04
.IP \fBTCSANOW\fP
Packit 7cfc04
the change occurs immediately.
Packit 7cfc04
.IP \fBTCSADRAIN\fP
Packit 7cfc04
the change occurs after all output written to
Packit 7cfc04
.I fd
Packit 7cfc04
has been transmitted.
Packit 7cfc04
This option should be used when changing
Packit 7cfc04
parameters that affect output.
Packit 7cfc04
.IP \fBTCSAFLUSH\fP
Packit 7cfc04
the change occurs after all output written to the object referred by
Packit 7cfc04
.I fd
Packit 7cfc04
has been transmitted, and all input that has been received but not read
Packit 7cfc04
will be discarded before the change is made.
Packit 7cfc04
.SS Canonical and noncanonical mode
Packit 7cfc04
The setting of the
Packit 7cfc04
.B ICANON
Packit 7cfc04
canon flag in
Packit 7cfc04
.I c_lflag
Packit 7cfc04
determines whether the terminal is operating in canonical mode
Packit 7cfc04
.RB ( ICANON
Packit 7cfc04
set) or
Packit 7cfc04
noncanonical mode
Packit 7cfc04
.RB ( ICANON
Packit 7cfc04
unset).
Packit 7cfc04
By default,
Packit 7cfc04
.B ICANON
Packit 7cfc04
is set.
Packit 7cfc04
.PP
Packit 7cfc04
In canonical mode:
Packit 7cfc04
.IP * 2
Packit 7cfc04
Input is made available line by line.
Packit 7cfc04
An input line is available when one of the line delimiters
Packit 7cfc04
is typed (NL, EOL, EOL2; or EOF at the start of line).
Packit 7cfc04
Except in the case of EOF, the line delimiter is included
Packit 7cfc04
in the buffer returned by
Packit 7cfc04
.BR read (2).
Packit 7cfc04
.IP * 2
Packit 7cfc04
Line editing is enabled (ERASE, KILL;
Packit 7cfc04
and if the
Packit 7cfc04
.B IEXTEN
Packit 7cfc04
flag is set: WERASE, REPRINT, LNEXT).
Packit 7cfc04
A
Packit 7cfc04
.BR read (2)
Packit 7cfc04
returns at most one line of input; if the
Packit 7cfc04
.BR read (2)
Packit 7cfc04
requested fewer bytes than are available in the current line of input,
Packit 7cfc04
then only as many bytes as requested are read,
Packit 7cfc04
and the remaining characters will be available for a future
Packit 7cfc04
.BR read (2).
Packit 7cfc04
.IP * 2
Packit 7cfc04
The maximum line length is 4096 chars
Packit 7cfc04
(including the terminating newline character);
Packit 7cfc04
lines longer than 4096 chars are truncated.
Packit 7cfc04
After 4095 characters, input processing (e.g.,
Packit 7cfc04
.B ISIG
Packit 7cfc04
and
Packit 7cfc04
.B ECHO*
Packit 7cfc04
processing) continues, but any input data after 4095 characters up to
Packit 7cfc04
(but not including) any terminating newline is discarded.
Packit 7cfc04
This ensures that the terminal can always receive
Packit 7cfc04
more input until at least one line can be read.
Packit 7cfc04
.PP
Packit 7cfc04
In noncanonical mode input is available immediately (without
Packit 7cfc04
the user having to type a line-delimiter character),
Packit 7cfc04
no input processing is performed,
Packit 7cfc04
and line editing is disabled.
Packit 7cfc04
The read buffer will only accept 4095 chars; this provides the
Packit 7cfc04
necessary space for a newline char if the input mode is switched
Packit 7cfc04
to canonical.
Packit 7cfc04
The settings of MIN
Packit 7cfc04
.RI ( c_cc[VMIN] )
Packit 7cfc04
and TIME
Packit 7cfc04
.RI ( c_cc[VTIME] )
Packit 7cfc04
determine the circumstances in which a
Packit 7cfc04
.BR read (2)
Packit 7cfc04
completes; there are four distinct cases:
Packit 7cfc04
.TP
Packit 7cfc04
MIN == 0, TIME == 0 (polling read)
Packit 7cfc04
If data is available,
Packit 7cfc04
.BR read (2)
Packit 7cfc04
returns immediately, with the lesser of the number of bytes
Packit 7cfc04
available, or the number of bytes requested.
Packit 7cfc04
If no data is available,
Packit 7cfc04
.BR read (2)
Packit 7cfc04
returns 0.
Packit 7cfc04
.TP
Packit 7cfc04
MIN > 0, TIME == 0 (blocking read)
Packit 7cfc04
.BR read (2)
Packit 7cfc04
blocks until MIN bytes are available,
Packit 7cfc04
and returns up to the number of bytes requested.
Packit 7cfc04
.TP
Packit 7cfc04
MIN == 0, TIME > 0 (read with timeout)
Packit 7cfc04
TIME specifies the limit for a timer in tenths of a second.
Packit 7cfc04
The timer is started when
Packit 7cfc04
.BR read (2)
Packit 7cfc04
is called.
Packit 7cfc04
.BR read (2)
Packit 7cfc04
returns either when at least one byte of data is available,
Packit 7cfc04
or when the timer expires.
Packit 7cfc04
If the timer expires without any input becoming available,
Packit 7cfc04
.BR read (2)
Packit 7cfc04
returns 0.
Packit 7cfc04
If data is already available at the time of the call to
Packit 7cfc04
.BR read (2),
Packit 7cfc04
the call behaves as though the data was received immediately after the call.
Packit 7cfc04
.TP
Packit 7cfc04
MIN > 0, TIME > 0 (read with interbyte timeout)
Packit 7cfc04
TIME specifies the limit for a timer in tenths of a second.
Packit 7cfc04
Once an initial byte of input becomes available,
Packit 7cfc04
the timer is restarted after each further byte is received.
Packit 7cfc04
.BR read (2)
Packit 7cfc04
returns when any of the following conditions is met:
Packit 7cfc04
.RS
Packit 7cfc04
.IP * 3
Packit 7cfc04
MIN bytes have been received.
Packit 7cfc04
.IP *
Packit 7cfc04
The interbyte timer expires.
Packit 7cfc04
.IP *
Packit 7cfc04
The number of bytes requested by
Packit 7cfc04
.BR read (2)
Packit 7cfc04
has been received.
Packit 7cfc04
(POSIX does not specify this termination condition,
Packit 7cfc04
and on some other implementations
Packit 7cfc04
.\" e.g., Solaris
Packit 7cfc04
.BR read (2)
Packit 7cfc04
does not return in this case.)
Packit 7cfc04
.RE
Packit 7cfc04
.IP
Packit 7cfc04
Because the timer is started only after the initial byte
Packit 7cfc04
becomes available, at least one byte will be read.
Packit 7cfc04
If data is already available at the time of the call to
Packit 7cfc04
.BR read (2),
Packit 7cfc04
the call behaves as though the data was received immediately after the call.
Packit 7cfc04
.PP
Packit 7cfc04
POSIX
Packit 7cfc04
.\" POSIX.1-2008 XBD 11.1.7
Packit 7cfc04
does not specify whether the setting of the
Packit 7cfc04
.B O_NONBLOCK
Packit 7cfc04
file status flag takes precedence over the MIN and TIME settings.
Packit 7cfc04
If
Packit 7cfc04
.B O_NONBLOCK
Packit 7cfc04
is set, a
Packit 7cfc04
.BR read (2)
Packit 7cfc04
in noncanonical mode may return immediately,
Packit 7cfc04
regardless of the setting of MIN or TIME.
Packit 7cfc04
Furthermore, if no data is available,
Packit 7cfc04
POSIX permits a
Packit 7cfc04
.BR read (2)
Packit 7cfc04
in noncanonical mode to return either 0, or \-1 with
Packit 7cfc04
.I errno
Packit 7cfc04
set to
Packit 7cfc04
.BR EAGAIN .
Packit 7cfc04
.SS Raw mode
Packit 7cfc04
.PP
Packit 7cfc04
.BR cfmakeraw ()
Packit 7cfc04
sets the terminal to something like the
Packit 7cfc04
"raw" mode of the old Version 7 terminal driver:
Packit 7cfc04
input is available character by character,
Packit 7cfc04
echoing is disabled, and all special processing of
Packit 7cfc04
terminal input and output characters is disabled.
Packit 7cfc04
The terminal attributes are set as follows:
Packit 7cfc04
.PP
Packit 7cfc04
.in +4n
Packit 7cfc04
.EX
Packit 7cfc04
termios_p\->c_iflag &= ~(IGNBRK | BRKINT | PARMRK | ISTRIP
Packit 7cfc04
                | INLCR | IGNCR | ICRNL | IXON);
Packit 7cfc04
termios_p\->c_oflag &= ~OPOST;
Packit 7cfc04
termios_p\->c_lflag &= ~(ECHO | ECHONL | ICANON | ISIG | IEXTEN);
Packit 7cfc04
termios_p\->c_cflag &= ~(CSIZE | PARENB);
Packit 7cfc04
termios_p\->c_cflag |= CS8;
Packit 7cfc04
.EE
Packit 7cfc04
.in
Packit 7cfc04
.\"
Packit 7cfc04
.SS Line control
Packit 7cfc04
.PP
Packit 7cfc04
.BR tcsendbreak ()
Packit 7cfc04
transmits a continuous stream of zero-valued bits for a specific
Packit 7cfc04
duration, if the terminal is using asynchronous serial data
Packit 7cfc04
transmission.
Packit 7cfc04
If \fIduration\fP is zero, it transmits zero-valued bits
Packit 7cfc04
for at least 0.25 seconds, and not more that 0.5 seconds.
Packit 7cfc04
If \fIduration\fP is not zero, it sends zero-valued bits for some
Packit 7cfc04
implementation-defined length of time.
Packit 7cfc04
.PP
Packit 7cfc04
If the terminal is not using asynchronous serial data transmission,
Packit 7cfc04
.BR tcsendbreak ()
Packit 7cfc04
returns without taking any action.
Packit 7cfc04
.PP
Packit 7cfc04
.BR tcdrain ()
Packit 7cfc04
waits until all output written to the object referred to by
Packit 7cfc04
.I fd
Packit 7cfc04
has been transmitted.
Packit 7cfc04
.PP
Packit 7cfc04
.BR tcflush ()
Packit 7cfc04
discards data written to the object referred to by
Packit 7cfc04
.I fd
Packit 7cfc04
but not transmitted, or data received but not read, depending on the
Packit 7cfc04
value of
Packit 7cfc04
.IR queue_selector :
Packit 7cfc04
.IP \fBTCIFLUSH\fP
Packit 7cfc04
flushes data received but not read.
Packit 7cfc04
.IP \fBTCOFLUSH\fP
Packit 7cfc04
flushes data written but not transmitted.
Packit 7cfc04
.IP \fBTCIOFLUSH\fP
Packit 7cfc04
flushes both data received but not read, and data written but not
Packit 7cfc04
transmitted.
Packit 7cfc04
.PP
Packit 7cfc04
.BR tcflow ()
Packit 7cfc04
suspends transmission or reception of data on the object referred to by
Packit 7cfc04
.IR fd ,
Packit 7cfc04
depending on the value of
Packit 7cfc04
.IR action :
Packit 7cfc04
.IP \fBTCOOFF\fP
Packit 7cfc04
suspends output.
Packit 7cfc04
.IP \fBTCOON\fP
Packit 7cfc04
restarts suspended output.
Packit 7cfc04
.IP \fBTCIOFF\fP
Packit 7cfc04
transmits a STOP character, which stops the terminal device from
Packit 7cfc04
transmitting data to the system.
Packit 7cfc04
.IP \fBTCION\fP
Packit 7cfc04
transmits a START character, which starts the terminal device
Packit 7cfc04
transmitting data to the system.
Packit 7cfc04
.PP
Packit 7cfc04
The default on open of a terminal file is that neither its input nor its
Packit 7cfc04
output is suspended.
Packit 7cfc04
.SS Line speed
Packit 7cfc04
The baud rate functions are provided for getting and setting the values
Packit 7cfc04
of the input and output baud rates in the \fItermios\fP structure.
Packit 7cfc04
The new values do not take effect
Packit 7cfc04
until
Packit 7cfc04
.BR tcsetattr ()
Packit 7cfc04
is successfully called.
Packit 7cfc04
.PP
Packit 7cfc04
Setting the speed to \fBB0\fP instructs the modem to "hang up".
Packit 7cfc04
The actual bit rate corresponding to \fBB38400\fP may be altered with
Packit 7cfc04
.BR setserial (8).
Packit 7cfc04
.PP
Packit 7cfc04
The input and output baud rates are stored in the \fItermios\fP
Packit 7cfc04
structure.
Packit 7cfc04
.PP
Packit 7cfc04
.BR cfgetospeed ()
Packit 7cfc04
returns the output baud rate stored in the \fItermios\fP structure
Packit 7cfc04
pointed to by
Packit 7cfc04
.IR termios_p .
Packit 7cfc04
.PP
Packit 7cfc04
.BR cfsetospeed ()
Packit 7cfc04
sets the output baud rate stored in the \fItermios\fP structure pointed
Packit 7cfc04
to by \fItermios_p\fP to \fIspeed\fP, which must be one of these constants:
Packit 7cfc04
.PP
Packit 7cfc04
.nf
Packit 7cfc04
.ft B
Packit 7cfc04
	B0
Packit 7cfc04
	B50
Packit 7cfc04
	B75
Packit 7cfc04
	B110
Packit 7cfc04
	B134
Packit 7cfc04
	B150
Packit 7cfc04
	B200
Packit 7cfc04
	B300
Packit 7cfc04
	B600
Packit 7cfc04
	B1200
Packit 7cfc04
	B1800
Packit 7cfc04
	B2400
Packit 7cfc04
	B4800
Packit 7cfc04
	B9600
Packit 7cfc04
	B19200
Packit 7cfc04
	B38400
Packit 7cfc04
	B57600
Packit 7cfc04
	B115200
Packit 7cfc04
	B230400
Packit 7cfc04
.ft P
Packit 7cfc04
.fi
Packit 7cfc04
.PP
Packit 7cfc04
The zero baud rate, \fBB0\fP,
Packit 7cfc04
is used to terminate the connection.
Packit 7cfc04
If B0 is specified, the modem control lines shall no longer be asserted.
Packit 7cfc04
Normally, this will disconnect the line.
Packit 7cfc04
\fBCBAUDEX\fP is a mask
Packit 7cfc04
for the speeds beyond those defined in POSIX.1 (57600 and above).
Packit 7cfc04
Thus, \fBB57600\fP & \fBCBAUDEX\fP is nonzero.
Packit 7cfc04
.PP
Packit 7cfc04
.BR cfgetispeed ()
Packit 7cfc04
returns the input baud rate stored in the \fItermios\fP structure.
Packit 7cfc04
.PP
Packit 7cfc04
.BR cfsetispeed ()
Packit 7cfc04
sets the input baud rate stored in the \fItermios\fP structure to
Packit 7cfc04
.IR speed ,
Packit 7cfc04
which must be specified as one of the \fBBnnn\fP constants listed above for
Packit 7cfc04
.BR cfsetospeed ().
Packit 7cfc04
If the input baud rate is set to zero, the input baud rate will be
Packit 7cfc04
equal to the output baud rate.
Packit 7cfc04
.PP
Packit 7cfc04
.BR cfsetspeed ()
Packit 7cfc04
is a 4.4BSD extension.
Packit 7cfc04
It takes the same arguments as
Packit 7cfc04
.BR cfsetispeed (),
Packit 7cfc04
and sets both input and output speed.
Packit 7cfc04
.SH RETURN VALUE
Packit 7cfc04
.PP
Packit 7cfc04
.BR cfgetispeed ()
Packit 7cfc04
returns the input baud rate stored in the
Packit 7cfc04
\fItermios\fP
Packit 7cfc04
structure.
Packit 7cfc04
.PP
Packit 7cfc04
.BR cfgetospeed ()
Packit 7cfc04
returns the output baud rate stored in the \fItermios\fP structure.
Packit 7cfc04
.PP
Packit 7cfc04
All other functions return:
Packit 7cfc04
.IP 0
Packit 7cfc04
on success.
Packit 7cfc04
.IP \-1
Packit 7cfc04
on failure and set
Packit 7cfc04
.I errno
Packit 7cfc04
to indicate the error.
Packit 7cfc04
.PP
Packit 7cfc04
Note that
Packit 7cfc04
.BR tcsetattr ()
Packit 7cfc04
returns success if \fIany\fP of the requested changes could be
Packit 7cfc04
successfully carried out.
Packit 7cfc04
Therefore, when making multiple changes
Packit 7cfc04
it may be necessary to follow this call with a further call to
Packit 7cfc04
.BR tcgetattr ()
Packit 7cfc04
to check that all changes have been performed successfully.
Packit 7cfc04
.SH ATTRIBUTES
Packit 7cfc04
For an explanation of the terms used in this section, see
Packit 7cfc04
.BR attributes (7).
Packit 7cfc04
.nh
Packit 7cfc04
.ad l
Packit 7cfc04
.TS
Packit 7cfc04
allbox;
Packit 7cfc04
lbw36 lb lb
Packit 7cfc04
l l l.
Packit 7cfc04
Interface	Attribute	Value
Packit 7cfc04
T{
Packit 7cfc04
.BR tcgetattr (),
Packit 7cfc04
.BR tcsetattr (),
Packit 7cfc04
.BR tcdrain (),
Packit 7cfc04
.BR tcflush (),
Packit 7cfc04
.BR tcflow (),
Packit 7cfc04
.BR tcsendbreak (),
Packit 7cfc04
.BR cfmakeraw (),
Packit 7cfc04
.BR cfgetispeed (),
Packit 7cfc04
.BR cfgetospeed (),
Packit 7cfc04
.BR cfsetispeed (),
Packit 7cfc04
.BR cfsetospeed (),
Packit 7cfc04
.BR cfsetspeed ()
Packit 7cfc04
T}	Thread safety	MT-Safe
Packit 7cfc04
.TE
Packit 7cfc04
.\" FIXME: The markings are different from that in the glibc manual.
Packit 7cfc04
.\" markings in glibc manual are more detailed:
Packit 7cfc04
.\"
Packit 7cfc04
.\"     tcsendbreak: MT-Unsafe race:tcattr(filedes)/bsd
Packit 7cfc04
.\"     tcflow: MT-Unsafe race:tcattr(filedes)/bsd
Packit 7cfc04
.\"
Packit 7cfc04
.\" glibc manual says /bsd indicate the preceding marker only applies
Packit 7cfc04
.\" when the underlying kernel is a BSD kernel.
Packit 7cfc04
.\" So, it is safety in Linux kernel.
Packit 7cfc04
.ad
Packit 7cfc04
.hy
Packit 7cfc04
.SH CONFORMING TO
Packit 7cfc04
.BR tcgetattr (),
Packit 7cfc04
.BR tcsetattr (),
Packit 7cfc04
.BR tcsendbreak (),
Packit 7cfc04
.BR tcdrain (),
Packit 7cfc04
.BR tcflush (),
Packit 7cfc04
.BR tcflow (),
Packit 7cfc04
.BR cfgetispeed (),
Packit 7cfc04
.BR cfgetospeed (),
Packit 7cfc04
.BR cfsetispeed (),
Packit 7cfc04
and
Packit 7cfc04
.BR cfsetospeed ()
Packit 7cfc04
are specified in POSIX.1-2001.
Packit 7cfc04
.PP
Packit 7cfc04
.BR cfmakeraw ()
Packit 7cfc04
and
Packit 7cfc04
.BR cfsetspeed ()
Packit 7cfc04
are nonstandard, but available on the BSDs.
Packit 7cfc04
.SH NOTES
Packit 7cfc04
UNIX\ V7 and several later systems have a list of baud rates
Packit 7cfc04
where after the fourteen values B0, ..., B9600 one finds the
Packit 7cfc04
two constants EXTA, EXTB ("External A" and "External B").
Packit 7cfc04
Many systems extend the list with much higher baud rates.
Packit 7cfc04
.PP
Packit 7cfc04
The effect of a nonzero \fIduration\fP with
Packit 7cfc04
.BR tcsendbreak ()
Packit 7cfc04
varies.
Packit 7cfc04
SunOS specifies a break of
Packit 7cfc04
.I "duration\ *\ N"
Packit 7cfc04
seconds, where \fIN\fP is at least 0.25, and not more than 0.5.
Packit 7cfc04
Linux, AIX, DU, Tru64 send a break of
Packit 7cfc04
.I duration
Packit 7cfc04
milliseconds.
Packit 7cfc04
FreeBSD and NetBSD and HP-UX and MacOS ignore the value of
Packit 7cfc04
.IR duration .
Packit 7cfc04
Under Solaris and UnixWare,
Packit 7cfc04
.BR tcsendbreak ()
Packit 7cfc04
with nonzero
Packit 7cfc04
.I duration
Packit 7cfc04
behaves like
Packit 7cfc04
.BR tcdrain ().
Packit 7cfc04
.\" libc4 until 4.7.5, glibc for sysv: EINVAL for duration > 0.
Packit 7cfc04
.\" libc4.7.6, libc5, glibc for unix: duration in ms.
Packit 7cfc04
.\" glibc for bsd: duration in us
Packit 7cfc04
.\" glibc for sunos4: ignore duration
Packit 7cfc04
.SH SEE ALSO
Packit 7cfc04
.BR reset (1),
Packit 7cfc04
.BR setterm (1),
Packit 7cfc04
.BR stty (1),
Packit 7cfc04
.BR tput (1),
Packit 7cfc04
.BR tset (1),
Packit 7cfc04
.BR tty (1),
Packit 7cfc04
.BR ioctl_console (2),
Packit 7cfc04
.BR ioctl_tty (2),
Packit 7cfc04
.BR setserial (8)
Packit 7cfc04
.SH COLOPHON
Packit 7cfc04
This page is part of release 4.15 of the Linux
Packit 7cfc04
.I man-pages
Packit 7cfc04
project.
Packit 7cfc04
A description of the project,
Packit 7cfc04
information about reporting bugs,
Packit 7cfc04
and the latest version of this page,
Packit 7cfc04
can be found at
Packit 7cfc04
\%https://www.kernel.org/doc/man\-pages/.