1994-05-30 19:09:18 +00:00
|
|
|
.\" Copyright (c) 1991, 1992, 1993
|
|
|
|
.\" The Regents of the University of California. All rights reserved.
|
|
|
|
.\"
|
|
|
|
.\" Redistribution and use in source and binary forms, with or without
|
|
|
|
.\" modification, are permitted provided that the following conditions
|
|
|
|
.\" are met:
|
|
|
|
.\" 1. Redistributions of source code must retain the above copyright
|
|
|
|
.\" notice, this list of conditions and the following disclaimer.
|
|
|
|
.\" 2. Redistributions in binary form must reproduce the above copyright
|
|
|
|
.\" notice, this list of conditions and the following disclaimer in the
|
|
|
|
.\" documentation and/or other materials provided with the distribution.
|
2014-03-14 03:07:51 +00:00
|
|
|
.\" 3. Neither the name of the University nor the names of its contributors
|
1994-05-30 19:09:18 +00:00
|
|
|
.\" may be used to endorse or promote products derived from this software
|
|
|
|
.\" without specific prior written permission.
|
|
|
|
.\"
|
|
|
|
.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
|
|
|
|
.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
|
|
|
.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
|
|
|
.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
|
|
|
|
.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
|
|
|
.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
|
|
|
.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
|
|
|
.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
|
|
|
.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
|
|
|
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
|
|
|
.\" SUCH DAMAGE.
|
|
|
|
.\"
|
|
|
|
.\" @(#)termios.4 8.4 (Berkeley) 4/19/94
|
1999-08-28 00:22:10 +00:00
|
|
|
.\" $FreeBSD$
|
1994-05-30 19:09:18 +00:00
|
|
|
.\"
|
2020-06-28 17:28:11 +00:00
|
|
|
.Dd June 28, 2020
|
1994-05-30 19:09:18 +00:00
|
|
|
.Dt TERMIOS 4
|
2001-07-10 15:31:11 +00:00
|
|
|
.Os
|
1994-05-30 19:09:18 +00:00
|
|
|
.Sh NAME
|
|
|
|
.Nm termios
|
|
|
|
.Nd general terminal line discipline
|
|
|
|
.Sh SYNOPSIS
|
2001-10-01 16:09:29 +00:00
|
|
|
.In termios.h
|
1994-05-30 19:09:18 +00:00
|
|
|
.Sh DESCRIPTION
|
|
|
|
This describes a general terminal line discipline that is
|
|
|
|
supported on tty asynchronous communication ports.
|
|
|
|
.Ss Opening a Terminal Device File
|
|
|
|
When a terminal file is opened, it normally causes the process to wait
|
2003-06-28 23:53:39 +00:00
|
|
|
until a connection is established.
|
|
|
|
For most hardware, the presence
|
1994-05-30 19:09:18 +00:00
|
|
|
of a connection is indicated by the assertion of the hardware
|
2001-02-01 16:38:02 +00:00
|
|
|
.Dv CARRIER
|
|
|
|
line.
|
1994-05-30 19:09:18 +00:00
|
|
|
If the termios structure associated with the terminal file has the
|
|
|
|
.Dv CLOCAL
|
|
|
|
flag set in the cflag, or if the
|
|
|
|
.Dv O_NONBLOCK
|
|
|
|
flag is set
|
|
|
|
in the
|
|
|
|
.Xr open 2
|
|
|
|
call, then the open will succeed even without
|
|
|
|
a connection being present.
|
|
|
|
In practice, applications
|
|
|
|
seldom open these files; they are opened by special programs, such
|
|
|
|
as
|
2019-08-13 15:41:36 +00:00
|
|
|
.Xr getty 8 ,
|
1994-05-30 19:09:18 +00:00
|
|
|
and become
|
|
|
|
an application's standard input, output, and error files.
|
|
|
|
.Ss Job Control in a Nutshell
|
|
|
|
Every process is associated with a particular process group and session.
|
|
|
|
The grouping is hierarchical: every member of a particular process group is a
|
2003-06-28 23:53:39 +00:00
|
|
|
member of the same session.
|
|
|
|
This structuring is used in managing groups
|
1994-05-30 19:09:18 +00:00
|
|
|
of related processes for purposes of
|
|
|
|
.\" .Gw "job control" ;
|
|
|
|
.Em "job control" ;
|
|
|
|
that is, the
|
|
|
|
ability from the keyboard (or from program control) to simultaneously
|
|
|
|
stop or restart
|
|
|
|
a complex command (a command composed of one or more related
|
2003-06-28 23:53:39 +00:00
|
|
|
processes).
|
|
|
|
The grouping into process groups allows delivering
|
1994-05-30 19:09:18 +00:00
|
|
|
of signals that stop or start the group as a whole, along with
|
|
|
|
arbitrating which process group has access to the single controlling
|
2003-06-28 23:53:39 +00:00
|
|
|
terminal.
|
|
|
|
The grouping at a higher layer into sessions is to restrict
|
1994-05-30 19:09:18 +00:00
|
|
|
the job control related signals and system calls to within processes
|
2003-06-28 23:53:39 +00:00
|
|
|
resulting from a particular instance of a
|
|
|
|
.Dq login .
|
|
|
|
Typically, a session
|
1994-05-30 19:09:18 +00:00
|
|
|
is created when a user logs in, and the login terminal is setup
|
|
|
|
to be the controlling terminal; all processes spawned from that
|
|
|
|
login shell are in the same session, and inherit the controlling
|
|
|
|
terminal.
|
1996-04-08 04:18:31 +00:00
|
|
|
.Pp
|
1994-05-30 19:09:18 +00:00
|
|
|
A job control shell
|
|
|
|
operating interactively (that is, reading commands from a terminal)
|
|
|
|
normally groups related processes together by placing them into the
|
2003-06-28 23:53:39 +00:00
|
|
|
same process group.
|
|
|
|
A set of processes in the same process group
|
|
|
|
is collectively referred to as a
|
|
|
|
.Dq job .
|
|
|
|
When the foreground process
|
1994-05-30 19:09:18 +00:00
|
|
|
group of the terminal is the same as the process group of a particular
|
2003-06-28 23:53:39 +00:00
|
|
|
job, that job is said to be in the
|
|
|
|
.Dq foreground .
|
|
|
|
When the process group of the terminal is different from the process group of
|
1994-05-30 19:09:18 +00:00
|
|
|
a job (but is still the controlling terminal), that job is said
|
2003-06-28 23:53:39 +00:00
|
|
|
to be in the
|
|
|
|
.Dq background .
|
|
|
|
Normally the
|
1994-05-30 19:09:18 +00:00
|
|
|
shell reads a command and starts the job that implements that
|
2003-06-28 23:53:39 +00:00
|
|
|
command.
|
|
|
|
If the command is to be started in the foreground (typical), it
|
1994-05-30 19:09:18 +00:00
|
|
|
sets the process group of the terminal to the process group
|
|
|
|
of the started job, waits for the job to complete, and then
|
|
|
|
sets the process group of the terminal back to its own process
|
2003-06-28 23:53:39 +00:00
|
|
|
group (it puts itself into the foreground).
|
|
|
|
If the job is to
|
1994-05-30 19:09:18 +00:00
|
|
|
be started in the background (as denoted by the shell operator "&"),
|
2005-02-13 22:25:33 +00:00
|
|
|
it never changes the process group of the terminal and does not
|
1994-05-30 19:09:18 +00:00
|
|
|
wait for the job to complete (that is, it immediately attempts to read the next
|
2003-06-28 23:53:39 +00:00
|
|
|
command).
|
|
|
|
If the job is started in the foreground, the user may
|
1994-05-30 19:09:18 +00:00
|
|
|
type a key (usually
|
|
|
|
.Ql \&^Z )
|
|
|
|
which generates the terminal stop signal
|
|
|
|
.Pq Dv SIGTSTP
|
2001-07-16 10:52:19 +00:00
|
|
|
and has the effect of stopping the entire job.
|
1994-05-30 19:09:18 +00:00
|
|
|
The shell will notice that the job stopped, and will resume running after
|
|
|
|
placing itself in the foreground.
|
|
|
|
The shell also has commands for placing stopped jobs in the background,
|
|
|
|
and for placing stopped or background jobs into the foreground.
|
|
|
|
.Ss Orphaned Process Groups
|
|
|
|
An orphaned process group is a process group that has no process
|
|
|
|
whose parent is in a different process group, yet is in the same
|
2003-06-28 23:53:39 +00:00
|
|
|
session.
|
2005-02-13 22:25:33 +00:00
|
|
|
Conceptually it means a process group that does not have
|
2003-06-28 23:53:39 +00:00
|
|
|
a parent that could do anything if it were to be stopped.
|
|
|
|
For example,
|
1994-05-30 19:09:18 +00:00
|
|
|
the initial login shell is typically in an orphaned process group.
|
|
|
|
Orphaned process groups are immune to keyboard generated stop
|
|
|
|
signals and job control signals resulting from reads or writes to the
|
|
|
|
controlling terminal.
|
|
|
|
.Ss The Controlling Terminal
|
2003-06-28 23:53:39 +00:00
|
|
|
A terminal may belong to a process as its controlling terminal.
|
|
|
|
Each
|
1994-05-30 19:09:18 +00:00
|
|
|
process of a session that has a controlling terminal has the same
|
2003-06-28 23:53:39 +00:00
|
|
|
controlling terminal.
|
|
|
|
A terminal may be the controlling terminal for at
|
|
|
|
most one session.
|
|
|
|
The controlling terminal for a session is allocated by
|
1994-05-30 19:09:18 +00:00
|
|
|
the session leader by issuing the
|
|
|
|
.Dv TIOCSCTTY
|
2004-07-03 18:29:24 +00:00
|
|
|
ioctl.
|
|
|
|
A controlling terminal
|
1994-05-30 19:09:18 +00:00
|
|
|
is never acquired by merely opening a terminal device file.
|
|
|
|
When a controlling terminal becomes
|
|
|
|
associated with a session, its foreground process group is set to
|
|
|
|
the process group of the session leader.
|
|
|
|
.Pp
|
|
|
|
The controlling terminal is inherited by a child process during a
|
|
|
|
.Xr fork 2
|
2003-06-28 23:53:39 +00:00
|
|
|
function call.
|
|
|
|
A process relinquishes its controlling terminal when it
|
1994-05-30 19:09:18 +00:00
|
|
|
creates a new session with the
|
1999-04-29 08:01:25 +00:00
|
|
|
.Xr setsid 2
|
1994-05-30 19:09:18 +00:00
|
|
|
function; other processes
|
|
|
|
remaining in the old session that had this terminal as their controlling
|
|
|
|
terminal continue to have it.
|
|
|
|
A process does not relinquish its
|
|
|
|
controlling terminal simply by closing all of its file descriptors
|
|
|
|
associated with the controlling terminal if other processes continue to
|
|
|
|
have it open.
|
|
|
|
.Pp
|
|
|
|
When a controlling process terminates, the controlling terminal is
|
|
|
|
disassociated from the current session, allowing it to be acquired by a
|
2003-06-28 23:53:39 +00:00
|
|
|
new session leader.
|
|
|
|
Subsequent access to the terminal by other processes
|
1994-05-30 19:09:18 +00:00
|
|
|
in the earlier session will be denied, with attempts to access the
|
|
|
|
terminal treated as if modem disconnect had been sensed.
|
|
|
|
.Ss Terminal Access Control
|
|
|
|
If a process is in the foreground process group of its controlling
|
|
|
|
terminal, read operations are allowed.
|
|
|
|
Any attempts by a process
|
|
|
|
in a background process group to read from its controlling terminal
|
|
|
|
causes a
|
|
|
|
.Dv SIGTTIN
|
|
|
|
signal to be sent to
|
|
|
|
the process's group
|
|
|
|
unless one of the
|
2004-07-03 18:29:24 +00:00
|
|
|
following special cases apply: if the reading process is ignoring or
|
1994-05-30 19:09:18 +00:00
|
|
|
blocking the
|
2000-05-09 14:02:06 +00:00
|
|
|
.Dv SIGTTIN
|
|
|
|
signal, or if the process group of the reading
|
1994-05-30 19:09:18 +00:00
|
|
|
process is orphaned, the
|
|
|
|
.Xr read 2
|
|
|
|
returns -1 with
|
2012-05-12 03:25:46 +00:00
|
|
|
.Va errno
|
|
|
|
set to
|
2000-11-22 16:11:48 +00:00
|
|
|
.Er EIO
|
1994-05-30 19:09:18 +00:00
|
|
|
and no
|
2004-07-03 18:29:24 +00:00
|
|
|
signal is sent.
|
|
|
|
The default action of the
|
1994-05-30 19:09:18 +00:00
|
|
|
.Dv SIGTTIN
|
|
|
|
signal is to stop the
|
|
|
|
process to which it is sent.
|
|
|
|
.Pp
|
|
|
|
If a process is in the foreground process group of its controlling
|
|
|
|
terminal, write operations are allowed.
|
|
|
|
Attempts by a process in a background process group to write to its
|
|
|
|
controlling terminal will cause the process group to be sent a
|
|
|
|
.Dv SIGTTOU
|
2004-07-03 18:29:24 +00:00
|
|
|
signal unless one of the following special cases apply: if
|
1994-05-30 19:09:18 +00:00
|
|
|
.Dv TOSTOP
|
|
|
|
is not
|
|
|
|
set, or if
|
|
|
|
.Dv TOSTOP
|
|
|
|
is set and the process is ignoring or blocking the
|
|
|
|
.Dv SIGTTOU
|
|
|
|
signal, the process is allowed to write to the terminal and the
|
|
|
|
.Dv SIGTTOU
|
2003-06-28 23:53:39 +00:00
|
|
|
signal is not sent.
|
|
|
|
If
|
1994-05-30 19:09:18 +00:00
|
|
|
.Dv TOSTOP
|
|
|
|
is set, and the process group of
|
|
|
|
the writing process is orphaned, and the writing process is not ignoring
|
|
|
|
or blocking
|
|
|
|
.Dv SIGTTOU ,
|
|
|
|
the
|
1996-04-08 04:18:31 +00:00
|
|
|
.Xr write 2
|
1994-05-30 19:09:18 +00:00
|
|
|
returns -1 with
|
|
|
|
errno set to
|
2000-11-22 16:11:48 +00:00
|
|
|
.Er EIO
|
1994-05-30 19:09:18 +00:00
|
|
|
and no signal is sent.
|
|
|
|
.Pp
|
|
|
|
Certain calls that set terminal parameters are treated in the same
|
|
|
|
fashion as write, except that
|
|
|
|
.Dv TOSTOP
|
|
|
|
is ignored; that is, the effect is
|
|
|
|
identical to that of terminal writes when
|
|
|
|
.Dv TOSTOP
|
|
|
|
is set.
|
|
|
|
.Ss Input Processing and Reading Data
|
|
|
|
A terminal device associated with a terminal device file may operate in
|
|
|
|
full-duplex mode, so that data may arrive even while output is occurring.
|
|
|
|
Each terminal device file has associated with it an input queue, into
|
|
|
|
which incoming data is stored by the system before being read by a
|
2004-07-03 18:29:24 +00:00
|
|
|
process.
|
|
|
|
The system imposes a limit,
|
1994-05-30 19:09:18 +00:00
|
|
|
.Pf \&{ Dv MAX_INPUT Ns \&} ,
|
|
|
|
on the number of
|
2003-06-28 23:53:39 +00:00
|
|
|
bytes that may be stored in the input queue.
|
|
|
|
The behavior of the system
|
1994-05-30 19:09:18 +00:00
|
|
|
when this limit is exceeded depends on the setting of the
|
|
|
|
.Dv IMAXBEL
|
|
|
|
flag in the termios
|
|
|
|
.Fa c_iflag .
|
|
|
|
If this flag is set, the terminal
|
|
|
|
is sent an
|
|
|
|
.Tn ASCII
|
|
|
|
.Dv BEL
|
|
|
|
character each time a character is received
|
2003-06-28 23:53:39 +00:00
|
|
|
while the input queue is full.
|
|
|
|
Otherwise, the input queue is flushed upon receiving the character.
|
1994-05-30 19:09:18 +00:00
|
|
|
.Pp
|
|
|
|
Two general kinds of input processing are available, determined by
|
|
|
|
whether the terminal device file is in canonical mode or noncanonical
|
2000-03-01 14:50:24 +00:00
|
|
|
mode.
|
|
|
|
Additionally,
|
1994-05-30 19:09:18 +00:00
|
|
|
input characters are processed according to the
|
|
|
|
.Fa c_iflag
|
|
|
|
and
|
|
|
|
.Fa c_lflag
|
2004-07-03 18:29:24 +00:00
|
|
|
fields.
|
|
|
|
Such processing can include echoing, which
|
1994-05-30 19:09:18 +00:00
|
|
|
in general means transmitting input characters immediately back to the
|
2003-06-28 23:53:39 +00:00
|
|
|
terminal when they are received from the terminal.
|
|
|
|
This is useful for terminals that can operate in full-duplex mode.
|
1994-05-30 19:09:18 +00:00
|
|
|
.Pp
|
|
|
|
The manner in which data is provided to a process reading from a terminal
|
|
|
|
device file is dependent on whether the terminal device file is in
|
|
|
|
canonical or noncanonical mode.
|
|
|
|
.Pp
|
|
|
|
Another dependency is whether the
|
|
|
|
.Dv O_NONBLOCK
|
|
|
|
flag is set by
|
1996-04-08 04:18:31 +00:00
|
|
|
.Xr open 2
|
1994-05-30 19:09:18 +00:00
|
|
|
or
|
1996-04-08 04:18:31 +00:00
|
|
|
.Xr fcntl 2 .
|
1994-05-30 19:09:18 +00:00
|
|
|
If the
|
|
|
|
.Dv O_NONBLOCK
|
|
|
|
flag is clear, then the read request is
|
2003-06-28 23:53:39 +00:00
|
|
|
blocked until data is available or a signal has been received.
|
|
|
|
If the
|
1994-05-30 19:09:18 +00:00
|
|
|
.Dv O_NONBLOCK
|
|
|
|
flag is set, then the read request is completed, without
|
|
|
|
blocking, in one of three ways:
|
|
|
|
.Bl -enum -offset indent
|
|
|
|
.It
|
|
|
|
If there is enough data available to satisfy the entire request,
|
|
|
|
and the read completes successfully the number of
|
|
|
|
bytes read is returned.
|
|
|
|
.It
|
|
|
|
If there is not enough data available to satisfy the entire
|
|
|
|
request, and the read completes successfully, having read as
|
|
|
|
much data as possible, the number of bytes read is returned.
|
|
|
|
.It
|
|
|
|
If there is no data available, the read returns -1, with
|
|
|
|
errno set to
|
|
|
|
.Er EAGAIN .
|
|
|
|
.El
|
|
|
|
.Pp
|
|
|
|
When data is available depends on whether the input processing mode is
|
|
|
|
canonical or noncanonical.
|
|
|
|
.Ss Canonical Mode Input Processing
|
|
|
|
In canonical mode input processing, terminal input is processed in units
|
2004-07-03 18:29:24 +00:00
|
|
|
of lines.
|
|
|
|
A line is delimited by a newline
|
1994-05-30 19:09:18 +00:00
|
|
|
.Ql \&\en
|
|
|
|
character, an end-of-file
|
|
|
|
.Pq Dv EOF
|
|
|
|
character, or an end-of-line
|
|
|
|
.Pq Dv EOL
|
2004-07-03 18:29:24 +00:00
|
|
|
character.
|
|
|
|
See the
|
1994-05-30 19:09:18 +00:00
|
|
|
.Sx "Special Characters"
|
|
|
|
section for
|
|
|
|
more information on
|
|
|
|
.Dv EOF
|
|
|
|
and
|
|
|
|
.Dv EOL .
|
|
|
|
This means that a read request will
|
|
|
|
not return until an entire line has been typed, or a signal has been
|
2003-06-28 23:53:39 +00:00
|
|
|
received.
|
|
|
|
Also, no matter how many bytes are requested in the read call,
|
|
|
|
at most one line is returned.
|
|
|
|
It is not, however, necessary to
|
1994-05-30 19:09:18 +00:00
|
|
|
read a whole line at once; any number of bytes, even one, may be
|
|
|
|
requested in a read without losing information.
|
|
|
|
.Pp
|
|
|
|
.Pf \&{ Dv MAX_CANON Ns \&}
|
|
|
|
is a limit on the
|
|
|
|
number of bytes in a line.
|
|
|
|
The behavior of the system when this limit is
|
|
|
|
exceeded is the same as when the input queue limit
|
|
|
|
.Pf \&{ Dv MAX_INPUT Ns \&} ,
|
|
|
|
is exceeded.
|
|
|
|
.Pp
|
|
|
|
Erase and kill processing occur when either of two special characters,
|
|
|
|
the
|
|
|
|
.Dv ERASE
|
|
|
|
and
|
|
|
|
.Dv KILL
|
|
|
|
characters (see the
|
2008-04-29 08:16:05 +00:00
|
|
|
.Sx "Special Characters"
|
|
|
|
section), is received.
|
1994-05-30 19:09:18 +00:00
|
|
|
This processing affects data in the input queue that has not yet been
|
|
|
|
delimited by a newline
|
2001-02-01 16:38:02 +00:00
|
|
|
.Dv NL ,
|
1994-05-30 19:09:18 +00:00
|
|
|
.Dv EOF ,
|
|
|
|
or
|
|
|
|
.Dv EOL
|
2004-07-03 18:29:24 +00:00
|
|
|
character.
|
|
|
|
This un-delimited
|
2003-06-28 23:53:39 +00:00
|
|
|
data makes up the current line.
|
|
|
|
The
|
1994-05-30 19:09:18 +00:00
|
|
|
.Dv ERASE
|
|
|
|
character deletes the last
|
2003-06-28 23:53:39 +00:00
|
|
|
character in the current line, if there is any.
|
|
|
|
The
|
1994-05-30 19:09:18 +00:00
|
|
|
.Dv KILL
|
|
|
|
character
|
2003-06-28 23:53:39 +00:00
|
|
|
deletes all data in the current line, if there is any.
|
|
|
|
The
|
1994-05-30 19:09:18 +00:00
|
|
|
.Dv ERASE
|
|
|
|
and
|
|
|
|
.Dv KILL
|
|
|
|
characters have no effect if there is no data in the current line.
|
|
|
|
The
|
|
|
|
.Dv ERASE
|
|
|
|
and
|
|
|
|
.Dv KILL
|
|
|
|
characters themselves are not placed in the input
|
|
|
|
queue.
|
|
|
|
.Ss Noncanonical Mode Input Processing
|
|
|
|
In noncanonical mode input processing, input bytes are not assembled into
|
2003-06-28 23:53:39 +00:00
|
|
|
lines, and erase and kill processing does not occur.
|
|
|
|
The values of the
|
1997-03-14 05:01:14 +00:00
|
|
|
.Dv VMIN
|
1994-05-30 19:09:18 +00:00
|
|
|
and
|
1997-03-14 05:01:14 +00:00
|
|
|
.Dv VTIME
|
1994-05-30 19:09:18 +00:00
|
|
|
members of the
|
|
|
|
.Fa c_cc
|
|
|
|
array are used to determine how to
|
|
|
|
process the bytes received.
|
|
|
|
.Pp
|
1997-03-18 07:17:22 +00:00
|
|
|
.Dv MIN
|
1994-05-30 19:09:18 +00:00
|
|
|
represents the minimum number of bytes that should be received when
|
|
|
|
the
|
1996-04-08 04:18:31 +00:00
|
|
|
.Xr read 2
|
1994-05-30 19:09:18 +00:00
|
|
|
function successfully returns.
|
1997-03-18 07:17:22 +00:00
|
|
|
.Dv TIME
|
1994-05-30 19:09:18 +00:00
|
|
|
is a timer of 0.1 second
|
|
|
|
granularity that is used to time out bursty and short term data
|
2004-07-03 18:29:24 +00:00
|
|
|
transmissions.
|
|
|
|
If
|
1997-03-18 07:17:22 +00:00
|
|
|
.Dv MIN
|
1994-05-30 19:09:18 +00:00
|
|
|
is greater than
|
|
|
|
.Dv \&{ Dv MAX_INPUT Ns \&} ,
|
|
|
|
the response to the
|
2003-06-28 23:53:39 +00:00
|
|
|
request is undefined.
|
|
|
|
The four possible values for
|
1997-03-18 07:17:22 +00:00
|
|
|
.Dv MIN
|
1994-05-30 19:09:18 +00:00
|
|
|
and
|
1997-03-18 07:17:22 +00:00
|
|
|
.Dv TIME
|
1994-05-30 19:09:18 +00:00
|
|
|
and
|
|
|
|
their interactions are described below.
|
1997-03-18 07:17:22 +00:00
|
|
|
.Ss "Case A: MIN > 0, TIME > 0"
|
1994-05-30 19:09:18 +00:00
|
|
|
In this case
|
1997-03-18 07:17:22 +00:00
|
|
|
.Dv TIME
|
1994-05-30 19:09:18 +00:00
|
|
|
serves as an inter-byte timer and is activated after
|
2003-06-28 23:53:39 +00:00
|
|
|
the first byte is received.
|
|
|
|
Since it is an inter-byte timer, it is reset
|
|
|
|
after a byte is received.
|
|
|
|
The interaction between
|
1997-03-18 07:17:22 +00:00
|
|
|
.Dv MIN
|
1994-05-30 19:09:18 +00:00
|
|
|
and
|
1997-03-18 07:17:22 +00:00
|
|
|
.Dv TIME
|
1994-05-30 19:09:18 +00:00
|
|
|
is as
|
2004-07-03 18:29:24 +00:00
|
|
|
follows: as soon as one byte is received, the inter-byte timer is
|
|
|
|
started.
|
|
|
|
If
|
1997-03-18 07:17:22 +00:00
|
|
|
.Dv MIN
|
1994-05-30 19:09:18 +00:00
|
|
|
bytes are received before the inter-byte timer expires
|
|
|
|
(remember that the timer is reset upon receipt of each byte), the read is
|
2003-06-28 23:53:39 +00:00
|
|
|
satisfied.
|
|
|
|
If the timer expires before
|
1997-03-18 07:17:22 +00:00
|
|
|
.Dv MIN
|
1994-05-30 19:09:18 +00:00
|
|
|
bytes are received, the
|
2003-06-28 23:53:39 +00:00
|
|
|
characters received to that point are returned to the user.
|
|
|
|
Note that if
|
1997-03-18 07:17:22 +00:00
|
|
|
.Dv TIME
|
1994-05-30 19:09:18 +00:00
|
|
|
expires at least one byte is returned because the timer would
|
2003-06-28 23:53:39 +00:00
|
|
|
not have been enabled unless a byte was received.
|
|
|
|
In this case
|
1997-03-18 07:17:22 +00:00
|
|
|
.Pf \&( Dv MIN
|
1994-05-30 19:09:18 +00:00
|
|
|
> 0,
|
1997-03-18 07:17:22 +00:00
|
|
|
.Dv TIME
|
1994-05-30 19:09:18 +00:00
|
|
|
> 0) the read blocks until the
|
1997-03-18 07:17:22 +00:00
|
|
|
.Dv MIN
|
1994-05-30 19:09:18 +00:00
|
|
|
and
|
1997-03-18 07:17:22 +00:00
|
|
|
.Dv TIME
|
1994-05-30 19:09:18 +00:00
|
|
|
mechanisms are
|
2003-06-28 23:53:39 +00:00
|
|
|
activated by the receipt of the first byte, or a signal is received.
|
|
|
|
If data is in the buffer at the time of the
|
1996-04-08 04:18:31 +00:00
|
|
|
.Fn read ,
|
|
|
|
the result is as
|
|
|
|
if data had been received immediately after the
|
|
|
|
.Fn read .
|
1997-03-18 07:17:22 +00:00
|
|
|
.Ss "Case B: MIN > 0, TIME = 0"
|
1994-05-30 19:09:18 +00:00
|
|
|
In this case, since the value of
|
1997-03-18 07:17:22 +00:00
|
|
|
.Dv TIME
|
1994-05-30 19:09:18 +00:00
|
|
|
is zero, the timer plays no role
|
|
|
|
and only
|
1997-03-18 07:17:22 +00:00
|
|
|
.Dv MIN
|
2003-06-28 23:53:39 +00:00
|
|
|
is significant.
|
|
|
|
A pending read is not satisfied until
|
1997-03-18 07:17:22 +00:00
|
|
|
.Dv MIN
|
1994-05-30 19:09:18 +00:00
|
|
|
bytes are received (i.e., the pending read blocks until
|
1997-03-18 07:17:22 +00:00
|
|
|
.Dv MIN
|
1994-05-30 19:09:18 +00:00
|
|
|
bytes
|
2003-06-28 23:53:39 +00:00
|
|
|
are received), or a signal is received.
|
|
|
|
A program that uses this case to read record-based terminal
|
1994-05-30 19:09:18 +00:00
|
|
|
.Dv I/O
|
|
|
|
may block indefinitely in the read
|
|
|
|
operation.
|
1997-03-18 07:17:22 +00:00
|
|
|
.Ss "Case C: MIN = 0, TIME > 0"
|
1994-05-30 19:09:18 +00:00
|
|
|
In this case, since
|
1997-03-18 07:17:22 +00:00
|
|
|
.Dv MIN
|
1994-05-30 19:09:18 +00:00
|
|
|
= 0,
|
1997-03-18 07:17:22 +00:00
|
|
|
.Dv TIME
|
1994-05-30 19:09:18 +00:00
|
|
|
no longer represents an inter-byte
|
2003-06-28 23:53:39 +00:00
|
|
|
timer.
|
|
|
|
It now serves as a read timer that is activated as soon as the
|
|
|
|
read function is processed.
|
|
|
|
A read is satisfied as soon as a single
|
|
|
|
byte is received or the read timer expires.
|
|
|
|
Note that in this case if the timer expires, no bytes are returned.
|
|
|
|
If the timer does not
|
1994-05-30 19:09:18 +00:00
|
|
|
expire, the only way the read can be satisfied is if a byte is received.
|
|
|
|
In this case the read will not block indefinitely waiting for a byte; if
|
|
|
|
no byte is received within
|
1997-03-18 07:17:22 +00:00
|
|
|
.Dv TIME Ns *0.1
|
1994-05-30 19:09:18 +00:00
|
|
|
seconds after the read is initiated,
|
2003-06-28 23:53:39 +00:00
|
|
|
the read returns a value of zero, having read no data.
|
|
|
|
If data is
|
1994-05-30 19:09:18 +00:00
|
|
|
in the buffer at the time of the read, the timer is started as if
|
|
|
|
data had been received immediately after the read.
|
1997-03-18 07:17:22 +00:00
|
|
|
.Ss Case D: MIN = 0, TIME = 0
|
1994-05-30 19:09:18 +00:00
|
|
|
The minimum of either the number of bytes requested or the number of
|
|
|
|
bytes currently available is returned without waiting for more
|
2003-06-28 23:53:39 +00:00
|
|
|
bytes to be input.
|
|
|
|
If no characters are available, read returns a
|
1994-05-30 19:09:18 +00:00
|
|
|
value of zero, having read no data.
|
|
|
|
.Ss Writing Data and Output Processing
|
|
|
|
When a process writes one or more bytes to a terminal device file, they
|
|
|
|
are processed according to the
|
|
|
|
.Fa c_oflag
|
|
|
|
field (see the
|
2008-04-29 08:16:05 +00:00
|
|
|
.Sx "Output Modes"
|
2004-07-03 18:29:24 +00:00
|
|
|
section).
|
|
|
|
The
|
1994-05-30 19:09:18 +00:00
|
|
|
implementation may provide a buffering mechanism; as such, when a call to
|
1996-04-08 04:18:31 +00:00
|
|
|
.Fn write
|
|
|
|
completes, all of the bytes written have been scheduled for
|
1994-05-30 19:09:18 +00:00
|
|
|
transmission to the device, but the transmission will not necessarily
|
|
|
|
have been completed.
|
|
|
|
.\" See also .Sx "6.4.2" for the effects of
|
|
|
|
.\" .Dv O_NONBLOCK
|
|
|
|
.\" on write.
|
|
|
|
.Ss Special Characters
|
|
|
|
Certain characters have special functions on input or output or both.
|
|
|
|
These functions are summarized as follows:
|
|
|
|
.Bl -tag -width indent
|
|
|
|
.It Dv INTR
|
|
|
|
Special character on input and is recognized if the
|
|
|
|
.Dv ISIG
|
|
|
|
flag (see the
|
|
|
|
.Sx "Local Modes"
|
2003-06-28 23:53:39 +00:00
|
|
|
section) is enabled.
|
|
|
|
Generates a
|
1994-05-30 19:09:18 +00:00
|
|
|
.Dv SIGINT
|
|
|
|
signal which is sent to all processes in the foreground
|
|
|
|
process group for which the terminal is the controlling
|
2004-07-03 18:29:24 +00:00
|
|
|
terminal.
|
|
|
|
If
|
1994-05-30 19:09:18 +00:00
|
|
|
.Dv ISIG
|
|
|
|
is set, the
|
|
|
|
.Dv INTR
|
|
|
|
character is
|
|
|
|
discarded when processed.
|
|
|
|
.It Dv QUIT
|
|
|
|
Special character on input and is recognized if the
|
|
|
|
.Dv ISIG
|
2003-06-28 23:53:39 +00:00
|
|
|
flag is enabled.
|
|
|
|
Generates a
|
1994-05-30 19:09:18 +00:00
|
|
|
.Dv SIGQUIT
|
|
|
|
signal which is
|
|
|
|
sent to all processes in the foreground process group
|
2003-06-28 23:53:39 +00:00
|
|
|
for which the terminal is the controlling terminal.
|
|
|
|
If
|
1994-05-30 19:09:18 +00:00
|
|
|
.Dv ISIG
|
|
|
|
is set, the
|
|
|
|
.Dv QUIT
|
|
|
|
character is discarded when
|
|
|
|
processed.
|
|
|
|
.It Dv ERASE
|
|
|
|
Special character on input and is recognized if the
|
|
|
|
.Dv ICANON
|
2003-06-28 23:53:39 +00:00
|
|
|
flag is set.
|
|
|
|
Erases the last character in the
|
1994-05-30 19:09:18 +00:00
|
|
|
current line; see
|
|
|
|
.Sx "Canonical Mode Input Processing" .
|
|
|
|
It does not erase beyond
|
|
|
|
the start of a line, as delimited by an
|
|
|
|
.Dv NL ,
|
|
|
|
.Dv EOF ,
|
|
|
|
or
|
|
|
|
.Dv EOL
|
2003-06-28 23:53:39 +00:00
|
|
|
character.
|
|
|
|
If
|
1994-05-30 19:09:18 +00:00
|
|
|
.Dv ICANON
|
|
|
|
is set, the
|
|
|
|
.Dv ERASE
|
|
|
|
character is
|
|
|
|
discarded when processed.
|
|
|
|
.It Dv KILL
|
|
|
|
Special character on input and is recognized if the
|
|
|
|
.Dv ICANON
|
2003-06-28 23:53:39 +00:00
|
|
|
flag is set.
|
|
|
|
Deletes the entire line, as
|
1994-05-30 19:09:18 +00:00
|
|
|
delimited by a
|
|
|
|
.Dv NL ,
|
|
|
|
.Dv EOF ,
|
|
|
|
or
|
|
|
|
.Dv EOL
|
2003-06-28 23:53:39 +00:00
|
|
|
character.
|
|
|
|
If
|
1994-05-30 19:09:18 +00:00
|
|
|
.Dv ICANON
|
|
|
|
is set, the
|
|
|
|
.Dv KILL
|
|
|
|
character is discarded when processed.
|
|
|
|
.It Dv EOF
|
|
|
|
Special character on input and is recognized if the
|
|
|
|
.Dv ICANON
|
2003-06-28 23:53:39 +00:00
|
|
|
flag is set.
|
|
|
|
When received, all the bytes
|
1994-05-30 19:09:18 +00:00
|
|
|
waiting to be read are immediately passed to the
|
|
|
|
process, without waiting for a newline, and the
|
|
|
|
.Dv EOF
|
2003-06-28 23:53:39 +00:00
|
|
|
is discarded.
|
|
|
|
Thus, if there are no bytes waiting (that is, the
|
1994-05-30 19:09:18 +00:00
|
|
|
.Dv EOF
|
|
|
|
occurred at the beginning of a line), a byte
|
2001-07-14 19:41:16 +00:00
|
|
|
count of zero is returned from the
|
1996-04-08 04:18:31 +00:00
|
|
|
.Fn read ,
|
2003-06-28 23:53:39 +00:00
|
|
|
representing an end-of-file indication.
|
|
|
|
If
|
1994-05-30 19:09:18 +00:00
|
|
|
.Dv ICANON
|
|
|
|
is
|
|
|
|
set, the
|
|
|
|
.Dv EOF
|
|
|
|
character is discarded when processed.
|
2000-09-18 23:00:15 +00:00
|
|
|
.It Dv NL
|
1994-05-30 19:09:18 +00:00
|
|
|
Special character on input and is recognized if the
|
|
|
|
.Dv ICANON
|
2003-06-28 23:53:39 +00:00
|
|
|
flag is set.
|
|
|
|
It is the line delimiter
|
1994-05-30 19:09:18 +00:00
|
|
|
.Ql \&\en .
|
|
|
|
.It Dv EOL
|
|
|
|
Special character on input and is recognized if the
|
|
|
|
.Dv ICANON
|
2003-06-28 23:53:39 +00:00
|
|
|
flag is set.
|
|
|
|
Is an additional line delimiter, like
|
1994-05-30 19:09:18 +00:00
|
|
|
.Dv NL .
|
|
|
|
.It Dv SUSP
|
|
|
|
If the
|
|
|
|
.Dv ISIG
|
|
|
|
flag is enabled, receipt of the
|
|
|
|
.Dv SUSP
|
|
|
|
character causes a
|
|
|
|
.Dv SIGTSTP
|
|
|
|
signal to be sent to all processes in the
|
|
|
|
foreground process group for which the terminal is the
|
|
|
|
controlling terminal, and the
|
|
|
|
.Dv SUSP
|
|
|
|
character is
|
|
|
|
discarded when processed.
|
|
|
|
.It Dv STOP
|
|
|
|
Special character on both input and output and is
|
|
|
|
recognized if the
|
|
|
|
.Dv IXON
|
|
|
|
(output control) or
|
|
|
|
.Dv IXOFF
|
|
|
|
(input
|
2003-06-28 23:53:39 +00:00
|
|
|
control) flag is set.
|
|
|
|
Can be used to temporarily suspend output.
|
|
|
|
It is useful with fast terminals to
|
1994-05-30 19:09:18 +00:00
|
|
|
prevent output from disappearing before it can be read.
|
|
|
|
If
|
|
|
|
.Dv IXON
|
|
|
|
is set, the
|
|
|
|
.Dv STOP
|
|
|
|
character is discarded when
|
|
|
|
processed.
|
|
|
|
.It Dv START
|
|
|
|
Special character on both input and output and is
|
|
|
|
recognized if the
|
|
|
|
.Dv IXON
|
|
|
|
(output control) or
|
|
|
|
.Dv IXOFF
|
|
|
|
(input
|
2003-06-28 23:53:39 +00:00
|
|
|
control) flag is set.
|
|
|
|
Can be used to resume output that has been suspended by a
|
1994-05-30 19:09:18 +00:00
|
|
|
.Dv STOP
|
2004-07-03 18:29:24 +00:00
|
|
|
character.
|
|
|
|
If
|
1994-05-30 19:09:18 +00:00
|
|
|
.Dv IXON
|
|
|
|
is set, the
|
|
|
|
.Dv START
|
|
|
|
character is discarded when processed.
|
2000-09-18 23:00:15 +00:00
|
|
|
.It Dv CR
|
1994-05-30 19:09:18 +00:00
|
|
|
Special character on input and is recognized if the
|
|
|
|
.Dv ICANON
|
|
|
|
flag is set; it is the
|
|
|
|
.Ql \&\er ,
|
|
|
|
as denoted in the
|
|
|
|
.Tn \&C
|
2003-06-28 23:53:39 +00:00
|
|
|
Standard {2}.
|
|
|
|
When
|
1994-05-30 19:09:18 +00:00
|
|
|
.Dv ICANON
|
|
|
|
and
|
|
|
|
.Dv ICRNL
|
|
|
|
are set and
|
|
|
|
.Dv IGNCR
|
|
|
|
is not set, this character is translated into a
|
|
|
|
.Dv NL ,
|
|
|
|
and
|
|
|
|
has the same effect as a
|
|
|
|
.Dv NL
|
|
|
|
character.
|
|
|
|
.El
|
|
|
|
.Pp
|
|
|
|
The following special characters are extensions defined by this
|
2001-02-26 15:57:37 +00:00
|
|
|
system and are not a part of
|
|
|
|
.St -p1003.1
|
|
|
|
termios.
|
1994-05-30 19:09:18 +00:00
|
|
|
.Bl -tag -width indent
|
|
|
|
.It Dv EOL2
|
|
|
|
Secondary
|
|
|
|
.Dv EOL
|
2004-07-03 18:29:24 +00:00
|
|
|
character.
|
|
|
|
Same function as
|
2001-02-01 16:38:02 +00:00
|
|
|
.Dv EOL .
|
1994-05-30 19:09:18 +00:00
|
|
|
.It Dv WERASE
|
|
|
|
Special character on input and is recognized if the
|
|
|
|
.Dv ICANON
|
2003-06-28 23:53:39 +00:00
|
|
|
flag is set.
|
|
|
|
Erases the last word in the current line according to one of two algorithms.
|
|
|
|
If the
|
1994-05-30 19:09:18 +00:00
|
|
|
.Dv ALTWERASE
|
|
|
|
flag is not set, first any preceding whitespace is
|
|
|
|
erased, and then the maximal sequence of non-whitespace
|
2003-06-28 23:53:39 +00:00
|
|
|
characters.
|
|
|
|
If
|
1994-05-30 19:09:18 +00:00
|
|
|
.Dv ALTWERASE
|
|
|
|
is set, first any preceding
|
|
|
|
whitespace is erased, and then the maximal sequence
|
|
|
|
of alphabetic/underscores or non alphabetic/underscores.
|
|
|
|
As a special case in this second algorithm, the first previous
|
|
|
|
non-whitespace character is skipped in determining
|
|
|
|
whether the preceding word is a sequence of
|
2003-06-28 23:53:39 +00:00
|
|
|
alphabetic/underscores.
|
|
|
|
This sounds confusing but turns out to be quite practical.
|
1994-05-30 19:09:18 +00:00
|
|
|
.It Dv REPRINT
|
|
|
|
Special character on input and is recognized if the
|
|
|
|
.Dv ICANON
|
2003-06-28 23:53:39 +00:00
|
|
|
flag is set.
|
|
|
|
Causes the current input edit line to be retyped.
|
1994-05-30 19:09:18 +00:00
|
|
|
.It Dv DSUSP
|
|
|
|
Has similar actions to the
|
|
|
|
.Dv SUSP
|
|
|
|
character, except that
|
|
|
|
the
|
|
|
|
.Dv SIGTSTP
|
|
|
|
signal is delivered when one of the processes
|
1996-04-08 04:18:31 +00:00
|
|
|
in the foreground process group issues a
|
|
|
|
.Fn read
|
|
|
|
to the
|
1994-05-30 19:09:18 +00:00
|
|
|
controlling terminal.
|
|
|
|
.It Dv LNEXT
|
|
|
|
Special character on input and is recognized if the
|
|
|
|
.Dv IEXTEN
|
2003-06-28 23:53:39 +00:00
|
|
|
flag is set.
|
|
|
|
Receipt of this character causes the next character to be taken literally.
|
1994-05-30 19:09:18 +00:00
|
|
|
.It Dv DISCARD
|
|
|
|
Special character on input and is recognized if the
|
|
|
|
.Dv IEXTEN
|
2003-06-28 23:53:39 +00:00
|
|
|
flag is set.
|
|
|
|
Receipt of this character toggles the flushing of terminal output.
|
1994-05-30 19:09:18 +00:00
|
|
|
.It Dv STATUS
|
|
|
|
Special character on input and is recognized if the
|
|
|
|
.Dv ICANON
|
2003-06-28 23:53:39 +00:00
|
|
|
flag is set.
|
|
|
|
Receipt of this character causes a
|
1994-05-30 19:09:18 +00:00
|
|
|
.Dv SIGINFO
|
|
|
|
signal to be sent to the foreground process group of the
|
2003-06-28 23:53:39 +00:00
|
|
|
terminal.
|
|
|
|
Also, if the
|
1994-05-30 19:09:18 +00:00
|
|
|
.Dv NOKERNINFO
|
|
|
|
flag is not set, it
|
|
|
|
causes the kernel to write a status message to the terminal
|
|
|
|
that displays the current load average, the name of the
|
|
|
|
command in the foreground, its process ID, the symbolic
|
|
|
|
wait channel, the number of user and system seconds used,
|
|
|
|
the percentage of cpu the process is getting, and the resident
|
|
|
|
set size of the process.
|
2020-06-27 16:31:04 +00:00
|
|
|
.Pp
|
|
|
|
In case the
|
|
|
|
.Xr sysctl 8
|
|
|
|
variable
|
|
|
|
.Va kern.tty_info_kstacks
|
2020-06-28 17:28:11 +00:00
|
|
|
is set to a non-zero value, the running thread's kernel stack is
|
2020-06-27 16:31:04 +00:00
|
|
|
written to the terminal (e.g., for debugging purposes).
|
1994-05-30 19:09:18 +00:00
|
|
|
.El
|
|
|
|
.Pp
|
|
|
|
The
|
|
|
|
.Dv NL
|
|
|
|
and
|
|
|
|
.Dv CR
|
|
|
|
characters cannot be changed.
|
|
|
|
The values for all the remaining characters can be set and are
|
|
|
|
described later in the document under
|
|
|
|
Special Control Characters.
|
|
|
|
.Pp
|
|
|
|
Special
|
|
|
|
character functions associated with changeable special control characters
|
|
|
|
can be disabled individually by setting their value to
|
2001-02-01 16:38:02 +00:00
|
|
|
.Dv {_POSIX_VDISABLE} ;
|
1994-05-30 19:09:18 +00:00
|
|
|
see
|
|
|
|
.Sx "Special Control Characters" .
|
|
|
|
.Pp
|
|
|
|
If two or more special characters have the same value, the function
|
|
|
|
performed when that character is received is undefined.
|
|
|
|
.Ss Modem Disconnect
|
|
|
|
If a modem disconnect is detected by the terminal interface for a
|
|
|
|
controlling terminal, and if
|
|
|
|
.Dv CLOCAL
|
|
|
|
is not set in the
|
|
|
|
.Fa c_cflag
|
|
|
|
field for
|
|
|
|
the terminal, the
|
|
|
|
.Dv SIGHUP
|
|
|
|
signal is sent to the controlling
|
2003-06-28 23:53:39 +00:00
|
|
|
process associated with the terminal.
|
|
|
|
Unless other arrangements have
|
1994-05-30 19:09:18 +00:00
|
|
|
been made, this causes the controlling process to terminate.
|
1996-04-08 04:18:31 +00:00
|
|
|
Any subsequent call to the
|
|
|
|
.Fn read
|
|
|
|
function returns the value zero,
|
2003-06-28 23:53:39 +00:00
|
|
|
indicating end of file.
|
|
|
|
Thus, processes that read a terminal
|
1994-05-30 19:09:18 +00:00
|
|
|
file and test for end-of-file can terminate appropriately after a
|
|
|
|
disconnect.
|
|
|
|
.\" If the
|
|
|
|
.\" .Er EIO
|
|
|
|
.\" condition specified in 6.1.1.4 that applies
|
|
|
|
.\" when the implementation supports job control also exists, it is
|
|
|
|
.\" unspecified whether the
|
|
|
|
.\" .Dv EOF
|
|
|
|
.\" condition or the
|
|
|
|
.\" .Pf [ Dv EIO
|
|
|
|
.\" ] is returned.
|
|
|
|
Any
|
1996-04-08 04:18:31 +00:00
|
|
|
subsequent
|
|
|
|
.Fn write
|
|
|
|
to the terminal device returns -1, with
|
1994-05-30 19:09:18 +00:00
|
|
|
.Va errno
|
|
|
|
set to
|
|
|
|
.Er EIO ,
|
|
|
|
until the device is closed.
|
|
|
|
.Sh General Terminal Interface
|
|
|
|
.Ss Closing a Terminal Device File
|
|
|
|
The last process to close a terminal device file causes any output
|
2003-06-28 23:53:39 +00:00
|
|
|
to be sent to the device and any input to be discarded.
|
|
|
|
Then, if
|
1994-05-30 19:09:18 +00:00
|
|
|
.Dv HUPCL
|
|
|
|
is set in the control modes, and the communications port supports a
|
|
|
|
disconnect function, the terminal device performs a disconnect.
|
|
|
|
.Ss Parameters That Can Be Set
|
|
|
|
Routines that need to control certain terminal
|
|
|
|
.Tn I/O
|
|
|
|
characteristics
|
|
|
|
do so by using the termios structure as defined in the header
|
2003-09-08 19:57:22 +00:00
|
|
|
.In termios.h .
|
1994-05-30 19:09:18 +00:00
|
|
|
This structure contains minimally four scalar elements of bit flags
|
2003-06-28 23:53:39 +00:00
|
|
|
and one array of special characters.
|
|
|
|
The scalar flag elements are named:
|
1994-05-30 19:09:18 +00:00
|
|
|
.Fa c_iflag ,
|
|
|
|
.Fa c_oflag ,
|
|
|
|
.Fa c_cflag ,
|
|
|
|
and
|
|
|
|
.Fa c_lflag .
|
|
|
|
The character array is named
|
|
|
|
.Fa c_cc ,
|
|
|
|
and its maximum index is
|
|
|
|
.Dv NCCS .
|
|
|
|
.Ss Input Modes
|
|
|
|
Values of the
|
|
|
|
.Fa c_iflag
|
|
|
|
field describe the basic
|
|
|
|
terminal input control, and are composed of
|
|
|
|
following masks:
|
|
|
|
.Pp
|
|
|
|
.Bl -tag -width IMAXBEL -offset indent -compact
|
|
|
|
.It Dv IGNBRK
|
|
|
|
/* ignore BREAK condition */
|
|
|
|
.It Dv BRKINT
|
|
|
|
/* map BREAK to SIGINTR */
|
|
|
|
.It Dv IGNPAR
|
|
|
|
/* ignore (discard) parity errors */
|
|
|
|
.It Dv PARMRK
|
|
|
|
/* mark parity and framing errors */
|
|
|
|
.It Dv INPCK
|
|
|
|
/* enable checking of parity errors */
|
|
|
|
.It Dv ISTRIP
|
|
|
|
/* strip 8th bit off chars */
|
|
|
|
.It Dv INLCR
|
|
|
|
/* map NL into CR */
|
|
|
|
.It Dv IGNCR
|
|
|
|
/* ignore CR */
|
|
|
|
.It Dv ICRNL
|
|
|
|
/* map CR to NL (ala CRMOD) */
|
|
|
|
.It Dv IXON
|
|
|
|
/* enable output flow control */
|
|
|
|
.It Dv IXOFF
|
|
|
|
/* enable input flow control */
|
|
|
|
.It Dv IXANY
|
|
|
|
/* any char will restart after stop */
|
|
|
|
.It Dv IMAXBEL
|
|
|
|
/* ring bell on input queue full */
|
|
|
|
.El
|
|
|
|
.Pp
|
|
|
|
In the context of asynchronous serial data transmission, a break
|
|
|
|
condition is defined as a sequence of zero-valued bits that continues for
|
2003-06-28 23:53:39 +00:00
|
|
|
more than the time to send one byte.
|
|
|
|
The entire sequence of zero-valued
|
1994-05-30 19:09:18 +00:00
|
|
|
bits is interpreted as a single break condition, even if it continues for
|
2003-06-28 23:53:39 +00:00
|
|
|
a time equivalent to more than one byte.
|
|
|
|
In contexts other than
|
1994-05-30 19:09:18 +00:00
|
|
|
asynchronous serial data transmission the definition of a break condition
|
|
|
|
is implementation defined.
|
|
|
|
.Pp
|
|
|
|
If
|
|
|
|
.Dv IGNBRK
|
|
|
|
is set, a break condition detected on input is ignored, that
|
2003-06-28 23:53:39 +00:00
|
|
|
is, not put on the input queue and therefore not read by any process.
|
|
|
|
If
|
1994-05-30 19:09:18 +00:00
|
|
|
.Dv IGNBRK
|
|
|
|
is not set and
|
|
|
|
.Dv BRKINT
|
|
|
|
is set, the break condition flushes the
|
|
|
|
input and output queues and if the terminal is the controlling terminal
|
|
|
|
of a foreground process group, the break condition generates a
|
|
|
|
single
|
|
|
|
.Dv SIGINT
|
2003-06-28 23:53:39 +00:00
|
|
|
signal to that foreground process group.
|
|
|
|
If neither
|
1994-05-30 19:09:18 +00:00
|
|
|
.Dv IGNBRK
|
|
|
|
nor
|
|
|
|
.Dv BRKINT
|
|
|
|
is set, a break condition is read as a single
|
|
|
|
.Ql \&\e0 ,
|
|
|
|
or if
|
|
|
|
.Dv PARMRK
|
|
|
|
is set, as
|
|
|
|
.Ql \&\e377 ,
|
|
|
|
.Ql \&\e0 ,
|
|
|
|
.Ql \&\e0 .
|
|
|
|
.Pp
|
|
|
|
If
|
|
|
|
.Dv IGNPAR
|
|
|
|
is set, a byte with a framing or parity error (other than
|
|
|
|
break) is ignored.
|
|
|
|
.Pp
|
|
|
|
If
|
|
|
|
.Dv PARMRK
|
|
|
|
is set, and
|
|
|
|
.Dv IGNPAR
|
|
|
|
is not set, a byte with a framing or parity
|
|
|
|
error (other than break) is given to the application as the
|
|
|
|
three-character sequence
|
|
|
|
.Ql \&\e377 ,
|
|
|
|
.Ql \&\e0 ,
|
|
|
|
X, where
|
|
|
|
.Ql \&\e377 ,
|
|
|
|
.Ql \&\e0
|
|
|
|
is a two-character
|
|
|
|
flag preceding each sequence and X is the data of the character received
|
2004-07-03 18:29:24 +00:00
|
|
|
in error.
|
|
|
|
To avoid ambiguity in this case, if
|
1994-05-30 19:09:18 +00:00
|
|
|
.Dv ISTRIP
|
|
|
|
is not set, a valid
|
|
|
|
character of
|
|
|
|
.Ql \&\e377
|
|
|
|
is given to the application as
|
|
|
|
.Ql \&\e377 ,
|
|
|
|
.Ql \&\e377 .
|
|
|
|
If
|
|
|
|
neither
|
|
|
|
.Dv PARMRK
|
|
|
|
nor
|
|
|
|
.Dv IGNPAR
|
|
|
|
is set, a framing or parity error (other than
|
|
|
|
break) is given to the application as a single character
|
|
|
|
.Ql \&\e0 .
|
|
|
|
.Pp
|
|
|
|
If
|
|
|
|
.Dv INPCK
|
2003-06-28 23:53:39 +00:00
|
|
|
is set, input parity checking is enabled.
|
|
|
|
If
|
1994-05-30 19:09:18 +00:00
|
|
|
.Dv INPCK
|
|
|
|
is not set,
|
|
|
|
input parity checking is disabled, allowing output parity generation
|
2003-06-28 23:53:39 +00:00
|
|
|
without input parity errors.
|
|
|
|
Note that whether input parity checking is
|
1994-05-30 19:09:18 +00:00
|
|
|
enabled or disabled is independent of whether parity detection is enabled
|
|
|
|
or disabled (see
|
|
|
|
.Sx "Control Modes" ) .
|
|
|
|
If parity detection is enabled but input
|
|
|
|
parity checking is disabled, the hardware to which the terminal is
|
|
|
|
connected recognizes the parity bit, but the terminal special file
|
|
|
|
does not check whether this bit is set correctly or not.
|
|
|
|
.Pp
|
|
|
|
If
|
|
|
|
.Dv ISTRIP
|
|
|
|
is set, valid input bytes are first stripped to seven bits,
|
|
|
|
otherwise all eight bits are processed.
|
|
|
|
.Pp
|
|
|
|
If
|
|
|
|
.Dv INLCR
|
|
|
|
is set, a received
|
|
|
|
.Dv NL
|
|
|
|
character is translated into a
|
|
|
|
.Dv CR
|
2004-07-03 18:29:24 +00:00
|
|
|
character.
|
|
|
|
If
|
1994-05-30 19:09:18 +00:00
|
|
|
.Dv IGNCR
|
|
|
|
is set, a received
|
|
|
|
.Dv CR
|
|
|
|
character is ignored (not
|
2004-07-03 18:29:24 +00:00
|
|
|
read).
|
|
|
|
If
|
1994-05-30 19:09:18 +00:00
|
|
|
.Dv IGNCR
|
|
|
|
is not set and
|
|
|
|
.Dv ICRNL
|
|
|
|
is set, a received
|
|
|
|
.Dv CR
|
|
|
|
character is
|
|
|
|
translated into a
|
|
|
|
.Dv NL
|
|
|
|
character.
|
|
|
|
.Pp
|
|
|
|
If
|
|
|
|
.Dv IXON
|
2003-06-28 23:53:39 +00:00
|
|
|
is set, start/stop output control is enabled.
|
|
|
|
A received
|
1994-05-30 19:09:18 +00:00
|
|
|
.Dv STOP
|
|
|
|
character suspends output and a received
|
|
|
|
.Dv START
|
|
|
|
character
|
2000-03-01 14:50:24 +00:00
|
|
|
restarts output.
|
|
|
|
If
|
1994-05-30 19:09:18 +00:00
|
|
|
.Dv IXANY
|
|
|
|
is also set, then any character may
|
2000-03-01 14:50:24 +00:00
|
|
|
restart output.
|
|
|
|
When
|
1994-05-30 19:09:18 +00:00
|
|
|
.Dv IXON
|
|
|
|
is set,
|
|
|
|
.Dv START
|
|
|
|
and
|
|
|
|
.Dv STOP
|
|
|
|
characters are not
|
2003-06-28 23:53:39 +00:00
|
|
|
read, but merely perform flow control functions.
|
|
|
|
When
|
1994-05-30 19:09:18 +00:00
|
|
|
.Dv IXON
|
|
|
|
is not set,
|
|
|
|
the
|
|
|
|
.Dv START
|
|
|
|
and
|
|
|
|
.Dv STOP
|
|
|
|
characters are read.
|
|
|
|
.Pp
|
|
|
|
If
|
|
|
|
.Dv IXOFF
|
2003-06-28 23:53:39 +00:00
|
|
|
is set, start/stop input control is enabled.
|
|
|
|
The system shall transmit one or more
|
1994-05-30 19:09:18 +00:00
|
|
|
.Dv STOP
|
|
|
|
characters, which are intended to cause the
|
|
|
|
terminal device to stop transmitting data, as needed to prevent the input
|
|
|
|
queue from overflowing and causing the undefined behavior described in
|
|
|
|
.Sx "Input Processing and Reading Data" ,
|
|
|
|
and shall transmit one or more
|
|
|
|
.Dv START
|
|
|
|
characters, which are
|
|
|
|
intended to cause the terminal device to resume transmitting data, as
|
|
|
|
soon as the device can continue transmitting data without risk of
|
2003-06-28 23:53:39 +00:00
|
|
|
overflowing the input queue.
|
|
|
|
The precise conditions under which
|
1994-05-30 19:09:18 +00:00
|
|
|
.Dv STOP
|
|
|
|
and
|
2010-08-16 15:18:30 +00:00
|
|
|
.Dv START
|
1994-05-30 19:09:18 +00:00
|
|
|
characters are transmitted are implementation defined.
|
|
|
|
.Pp
|
|
|
|
If
|
|
|
|
.Dv IMAXBEL
|
|
|
|
is set and the input queue is full, subsequent input shall cause an
|
|
|
|
.Tn ASCII
|
|
|
|
.Dv BEL
|
1999-02-12 02:12:08 +00:00
|
|
|
character to be transmitted to
|
1994-05-30 19:09:18 +00:00
|
|
|
the output queue.
|
|
|
|
.Pp
|
2001-07-14 19:41:16 +00:00
|
|
|
The initial input control value after
|
1996-04-08 04:18:31 +00:00
|
|
|
.Fn open
|
|
|
|
is implementation defined.
|
1994-05-30 19:09:18 +00:00
|
|
|
.Ss Output Modes
|
|
|
|
Values of the
|
|
|
|
.Fa c_oflag
|
|
|
|
field describe the basic terminal output control,
|
|
|
|
and are composed of the following masks:
|
|
|
|
.Pp
|
Integrate the new MPSAFE TTY layer to the FreeBSD operating system.
The last half year I've been working on a replacement TTY layer for the
FreeBSD kernel. The new TTY layer was designed to improve the following:
- Improved driver model:
The old TTY layer has a driver model that is not abstract enough to
make it friendly to use. A good example is the output path, where the
device drivers directly access the output buffers. This means that an
in-kernel PPP implementation must always convert network buffers into
TTY buffers.
If a PPP implementation would be built on top of the new TTY layer
(still needs a hooks layer, though), it would allow the PPP
implementation to directly hand the data to the TTY driver.
- Improved hotplugging:
With the old TTY layer, it isn't entirely safe to destroy TTY's from
the system. This implementation has a two-step destructing design,
where the driver first abandons the TTY. After all threads have left
the TTY, the TTY layer calls a routine in the driver, which can be
used to free resources (unit numbers, etc).
The pts(4) driver also implements this feature, which means
posix_openpt() will now return PTY's that are created on the fly.
- Improved performance:
One of the major improvements is the per-TTY mutex, which is expected
to improve scalability when compared to the old Giant locking.
Another change is the unbuffered copying to userspace, which is both
used on TTY device nodes and PTY masters.
Upgrading should be quite straightforward. Unlike previous versions,
existing kernel configuration files do not need to be changed, except
when they reference device drivers that are listed in UPDATING.
Obtained from: //depot/projects/mpsafetty/...
Approved by: philip (ex-mentor)
Discussed: on the lists, at BSDCan, at the DevSummit
Sponsored by: Snow B.V., the Netherlands
dcons(4) fixed by: kan
2008-08-20 08:31:58 +00:00
|
|
|
.Bl -tag -width ONOEOT -offset indent -compact
|
1994-05-30 19:09:18 +00:00
|
|
|
.It Dv OPOST
|
|
|
|
/* enable following output processing */
|
|
|
|
.It Dv ONLCR
|
|
|
|
/* map NL to CR-NL (ala
|
2001-02-01 16:38:02 +00:00
|
|
|
.Dv CRMOD )
|
1994-05-30 19:09:18 +00:00
|
|
|
*/
|
2001-03-04 06:04:50 +00:00
|
|
|
.It Dv OCRNL
|
|
|
|
/* map CR to NL */
|
Integrate the new MPSAFE TTY layer to the FreeBSD operating system.
The last half year I've been working on a replacement TTY layer for the
FreeBSD kernel. The new TTY layer was designed to improve the following:
- Improved driver model:
The old TTY layer has a driver model that is not abstract enough to
make it friendly to use. A good example is the output path, where the
device drivers directly access the output buffers. This means that an
in-kernel PPP implementation must always convert network buffers into
TTY buffers.
If a PPP implementation would be built on top of the new TTY layer
(still needs a hooks layer, though), it would allow the PPP
implementation to directly hand the data to the TTY driver.
- Improved hotplugging:
With the old TTY layer, it isn't entirely safe to destroy TTY's from
the system. This implementation has a two-step destructing design,
where the driver first abandons the TTY. After all threads have left
the TTY, the TTY layer calls a routine in the driver, which can be
used to free resources (unit numbers, etc).
The pts(4) driver also implements this feature, which means
posix_openpt() will now return PTY's that are created on the fly.
- Improved performance:
One of the major improvements is the per-TTY mutex, which is expected
to improve scalability when compared to the old Giant locking.
Another change is the unbuffered copying to userspace, which is both
used on TTY device nodes and PTY masters.
Upgrading should be quite straightforward. Unlike previous versions,
existing kernel configuration files do not need to be changed, except
when they reference device drivers that are listed in UPDATING.
Obtained from: //depot/projects/mpsafetty/...
Approved by: philip (ex-mentor)
Discussed: on the lists, at BSDCan, at the DevSummit
Sponsored by: Snow B.V., the Netherlands
dcons(4) fixed by: kan
2008-08-20 08:31:58 +00:00
|
|
|
.It Dv TABDLY
|
|
|
|
/* tab delay mask */
|
|
|
|
.It Dv TAB0
|
|
|
|
/* no tab delay and expansion */
|
|
|
|
.It Dv TAB3
|
1994-05-30 19:09:18 +00:00
|
|
|
/* expand tabs to spaces */
|
|
|
|
.It Dv ONOEOT
|
|
|
|
/* discard
|
|
|
|
.Dv EOT Ns 's
|
|
|
|
.Ql \&^D
|
|
|
|
on output) */
|
2001-03-04 06:04:50 +00:00
|
|
|
.It Dv ONOCR
|
|
|
|
/* do not transmit CRs on column 0 */
|
|
|
|
.It Dv ONLRET
|
2002-01-21 12:09:13 +00:00
|
|
|
/* on the terminal NL performs the CR function */
|
1994-05-30 19:09:18 +00:00
|
|
|
.El
|
|
|
|
.Pp
|
|
|
|
If
|
|
|
|
.Dv OPOST
|
|
|
|
is set, the remaining flag masks are interpreted as follows;
|
|
|
|
otherwise characters are transmitted without change.
|
|
|
|
.Pp
|
|
|
|
If
|
|
|
|
.Dv ONLCR
|
|
|
|
is set, newlines are translated to carriage return, linefeeds.
|
|
|
|
.Pp
|
|
|
|
If
|
2001-03-04 06:04:50 +00:00
|
|
|
.Dv OCRNL
|
|
|
|
is set, carriage returns are translated to newlines.
|
|
|
|
.Pp
|
Integrate the new MPSAFE TTY layer to the FreeBSD operating system.
The last half year I've been working on a replacement TTY layer for the
FreeBSD kernel. The new TTY layer was designed to improve the following:
- Improved driver model:
The old TTY layer has a driver model that is not abstract enough to
make it friendly to use. A good example is the output path, where the
device drivers directly access the output buffers. This means that an
in-kernel PPP implementation must always convert network buffers into
TTY buffers.
If a PPP implementation would be built on top of the new TTY layer
(still needs a hooks layer, though), it would allow the PPP
implementation to directly hand the data to the TTY driver.
- Improved hotplugging:
With the old TTY layer, it isn't entirely safe to destroy TTY's from
the system. This implementation has a two-step destructing design,
where the driver first abandons the TTY. After all threads have left
the TTY, the TTY layer calls a routine in the driver, which can be
used to free resources (unit numbers, etc).
The pts(4) driver also implements this feature, which means
posix_openpt() will now return PTY's that are created on the fly.
- Improved performance:
One of the major improvements is the per-TTY mutex, which is expected
to improve scalability when compared to the old Giant locking.
Another change is the unbuffered copying to userspace, which is both
used on TTY device nodes and PTY masters.
Upgrading should be quite straightforward. Unlike previous versions,
existing kernel configuration files do not need to be changed, except
when they reference device drivers that are listed in UPDATING.
Obtained from: //depot/projects/mpsafetty/...
Approved by: philip (ex-mentor)
Discussed: on the lists, at BSDCan, at the DevSummit
Sponsored by: Snow B.V., the Netherlands
dcons(4) fixed by: kan
2008-08-20 08:31:58 +00:00
|
|
|
The
|
|
|
|
.Dv TABDLY
|
|
|
|
bits specify the tab delay.
|
|
|
|
The
|
|
|
|
.Fa c_oflag
|
|
|
|
is masked with
|
|
|
|
.Dv TABDLY
|
|
|
|
and compared with the
|
|
|
|
values
|
|
|
|
.Dv TAB0
|
|
|
|
or
|
|
|
|
.Dv TAB3 .
|
2001-03-04 06:04:50 +00:00
|
|
|
If
|
Integrate the new MPSAFE TTY layer to the FreeBSD operating system.
The last half year I've been working on a replacement TTY layer for the
FreeBSD kernel. The new TTY layer was designed to improve the following:
- Improved driver model:
The old TTY layer has a driver model that is not abstract enough to
make it friendly to use. A good example is the output path, where the
device drivers directly access the output buffers. This means that an
in-kernel PPP implementation must always convert network buffers into
TTY buffers.
If a PPP implementation would be built on top of the new TTY layer
(still needs a hooks layer, though), it would allow the PPP
implementation to directly hand the data to the TTY driver.
- Improved hotplugging:
With the old TTY layer, it isn't entirely safe to destroy TTY's from
the system. This implementation has a two-step destructing design,
where the driver first abandons the TTY. After all threads have left
the TTY, the TTY layer calls a routine in the driver, which can be
used to free resources (unit numbers, etc).
The pts(4) driver also implements this feature, which means
posix_openpt() will now return PTY's that are created on the fly.
- Improved performance:
One of the major improvements is the per-TTY mutex, which is expected
to improve scalability when compared to the old Giant locking.
Another change is the unbuffered copying to userspace, which is both
used on TTY device nodes and PTY masters.
Upgrading should be quite straightforward. Unlike previous versions,
existing kernel configuration files do not need to be changed, except
when they reference device drivers that are listed in UPDATING.
Obtained from: //depot/projects/mpsafetty/...
Approved by: philip (ex-mentor)
Discussed: on the lists, at BSDCan, at the DevSummit
Sponsored by: Snow B.V., the Netherlands
dcons(4) fixed by: kan
2008-08-20 08:31:58 +00:00
|
|
|
.Dv TAB3
|
1994-05-30 19:09:18 +00:00
|
|
|
is set, tabs are expanded to the appropriate number of
|
|
|
|
spaces (assuming 8 column tab stops).
|
|
|
|
.Pp
|
|
|
|
If
|
|
|
|
.Dv ONOEOT
|
|
|
|
is set,
|
|
|
|
.Tn ASCII
|
2000-11-22 13:49:11 +00:00
|
|
|
.Dv EOT Ns 's
|
1994-05-30 19:09:18 +00:00
|
|
|
are discarded on output.
|
2001-03-04 06:04:50 +00:00
|
|
|
.Pp
|
|
|
|
If
|
|
|
|
.Dv ONOCR
|
|
|
|
is set, no CR character is transmitted when at column 0 (first position).
|
|
|
|
.Pp
|
|
|
|
If
|
|
|
|
.Dv ONLRET
|
|
|
|
is set, the NL character is assumed to do the carriage-return function;
|
|
|
|
the column pointer will be set to 0.
|
1994-05-30 19:09:18 +00:00
|
|
|
.Ss Control Modes
|
|
|
|
Values of the
|
|
|
|
.Fa c_cflag
|
|
|
|
field describe the basic
|
|
|
|
terminal hardware control, and are composed of the
|
|
|
|
following masks.
|
|
|
|
Not all values
|
|
|
|
specified are supported by all hardware.
|
|
|
|
.Pp
|
|
|
|
.Bl -tag -width CRTSXIFLOW -offset indent -compact
|
|
|
|
.It Dv CSIZE
|
|
|
|
/* character size mask */
|
|
|
|
.It Dv CS5
|
|
|
|
/* 5 bits (pseudo) */
|
|
|
|
.It Dv CS6
|
|
|
|
/* 6 bits */
|
|
|
|
.It Dv CS7
|
|
|
|
/* 7 bits */
|
|
|
|
.It Dv CS8
|
|
|
|
/* 8 bits */
|
|
|
|
.It Dv CSTOPB
|
|
|
|
/* send 2 stop bits */
|
|
|
|
.It Dv CREAD
|
|
|
|
/* enable receiver */
|
|
|
|
.It Dv PARENB
|
|
|
|
/* parity enable */
|
|
|
|
.It Dv PARODD
|
|
|
|
/* odd parity, else even */
|
|
|
|
.It Dv HUPCL
|
|
|
|
/* hang up on last close */
|
|
|
|
.It Dv CLOCAL
|
|
|
|
/* ignore modem status lines */
|
|
|
|
.It Dv CCTS_OFLOW
|
|
|
|
/*
|
|
|
|
.Dv CTS
|
|
|
|
flow control of output */
|
|
|
|
.It Dv CRTSCTS
|
|
|
|
/* same as
|
|
|
|
.Dv CCTS_OFLOW
|
|
|
|
*/
|
|
|
|
.It Dv CRTS_IFLOW
|
|
|
|
/* RTS flow control of input */
|
|
|
|
.It Dv MDMBUF
|
|
|
|
/* flow control output via Carrier */
|
2019-06-12 18:07:04 +00:00
|
|
|
.It Dv CNO_RTSDTR
|
|
|
|
/* Do not assert RTS or DTR automatically */
|
1994-05-30 19:09:18 +00:00
|
|
|
.El
|
|
|
|
.Pp
|
|
|
|
The
|
|
|
|
.Dv CSIZE
|
|
|
|
bits specify the byte size in bits for both transmission and
|
2003-06-28 23:53:39 +00:00
|
|
|
reception.
|
|
|
|
The
|
1994-05-30 19:09:18 +00:00
|
|
|
.Fa c_cflag
|
|
|
|
is masked with
|
|
|
|
.Dv CSIZE
|
|
|
|
and compared with the
|
|
|
|
values
|
|
|
|
.Dv CS5 ,
|
|
|
|
.Dv CS6 ,
|
|
|
|
.Dv CS7 ,
|
|
|
|
or
|
|
|
|
.Dv CS8 .
|
2003-06-28 23:53:39 +00:00
|
|
|
This size does not include the parity bit, if any.
|
|
|
|
If
|
1994-05-30 19:09:18 +00:00
|
|
|
.Dv CSTOPB
|
2003-06-28 23:53:39 +00:00
|
|
|
is set, two stop bits are used, otherwise one stop bit.
|
|
|
|
For example, at 110 baud, two stop bits are normally used.
|
1994-05-30 19:09:18 +00:00
|
|
|
.Pp
|
|
|
|
If
|
|
|
|
.Dv CREAD
|
2003-06-28 23:53:39 +00:00
|
|
|
is set, the receiver is enabled.
|
|
|
|
Otherwise, no character is received.
|
|
|
|
Not all hardware supports this bit.
|
|
|
|
In fact, this flag is pretty silly and if it were not part of the
|
2000-11-20 18:41:33 +00:00
|
|
|
.Nm
|
1994-05-30 19:09:18 +00:00
|
|
|
specification
|
|
|
|
it would be omitted.
|
|
|
|
.Pp
|
|
|
|
If
|
|
|
|
.Dv PARENB
|
|
|
|
is set, parity generation and detection are enabled and a parity
|
2003-06-28 23:53:39 +00:00
|
|
|
bit is added to each character.
|
|
|
|
If parity is enabled,
|
1994-05-30 19:09:18 +00:00
|
|
|
.Dv PARODD
|
|
|
|
specifies
|
|
|
|
odd parity if set, otherwise even parity is used.
|
|
|
|
.Pp
|
|
|
|
If
|
|
|
|
.Dv HUPCL
|
|
|
|
is set, the modem control lines for the port are lowered
|
|
|
|
when the last process with the port open closes the port or the process
|
2003-06-28 23:53:39 +00:00
|
|
|
terminates.
|
|
|
|
The modem connection is broken.
|
1994-05-30 19:09:18 +00:00
|
|
|
.Pp
|
|
|
|
If
|
|
|
|
.Dv CLOCAL
|
|
|
|
is set, a connection does not depend on the state of the modem
|
2003-06-28 23:53:39 +00:00
|
|
|
status lines.
|
|
|
|
If
|
1994-05-30 19:09:18 +00:00
|
|
|
.Dv CLOCAL
|
|
|
|
is clear, the modem status lines are
|
|
|
|
monitored.
|
|
|
|
.Pp
|
2001-07-14 19:41:16 +00:00
|
|
|
Under normal circumstances, a call to the
|
1996-04-08 04:18:31 +00:00
|
|
|
.Fn open
|
|
|
|
function waits for
|
2003-06-28 23:53:39 +00:00
|
|
|
the modem connection to complete.
|
|
|
|
However, if the
|
1994-05-30 19:09:18 +00:00
|
|
|
.Dv O_NONBLOCK
|
|
|
|
flag is set
|
|
|
|
or if
|
|
|
|
.Dv CLOCAL
|
2001-07-14 19:41:16 +00:00
|
|
|
has been set, the
|
1996-04-08 04:18:31 +00:00
|
|
|
.Fn open
|
|
|
|
function returns
|
1994-05-30 19:09:18 +00:00
|
|
|
immediately without waiting for the connection.
|
|
|
|
.Pp
|
|
|
|
The
|
|
|
|
.Dv CCTS_OFLOW
|
|
|
|
.Pf ( Dv CRTSCTS )
|
|
|
|
flag is currently unused.
|
|
|
|
.Pp
|
|
|
|
If
|
|
|
|
.Dv MDMBUF
|
|
|
|
is set then output flow control is controlled by the state
|
|
|
|
of Carrier Detect.
|
|
|
|
.Pp
|
2019-06-12 18:07:04 +00:00
|
|
|
If
|
|
|
|
.Dv CNO_RTSDTR
|
|
|
|
is set then the RTS and DTR lines will not be asserted when the device
|
|
|
|
is opened.
|
|
|
|
As a result, this flag is only useful on initial-state devices.
|
|
|
|
.Pp
|
1994-05-30 19:09:18 +00:00
|
|
|
If the object for which the control modes are set is not an asynchronous
|
|
|
|
serial connection, some of the modes may be ignored; for example, if an
|
|
|
|
attempt is made to set the baud rate on a network connection to a
|
|
|
|
terminal on another host, the baud rate may or may not be set on the
|
|
|
|
connection between that terminal and the machine it is directly connected
|
|
|
|
to.
|
|
|
|
.Ss Local Modes
|
|
|
|
Values of the
|
|
|
|
.Fa c_lflag
|
|
|
|
field describe the control of
|
|
|
|
various functions, and are composed of the following
|
|
|
|
masks.
|
|
|
|
.Pp
|
|
|
|
.Bl -tag -width NOKERNINFO -offset indent -compact
|
|
|
|
.It Dv ECHOKE
|
|
|
|
/* visual erase for line kill */
|
|
|
|
.It Dv ECHOE
|
|
|
|
/* visually erase chars */
|
|
|
|
.It Dv ECHO
|
|
|
|
/* enable echoing */
|
|
|
|
.It Dv ECHONL
|
|
|
|
/* echo
|
|
|
|
.Dv NL
|
|
|
|
even if
|
|
|
|
.Dv ECHO
|
|
|
|
is off */
|
|
|
|
.It Dv ECHOPRT
|
|
|
|
/* visual erase mode for hardcopy */
|
|
|
|
.It Dv ECHOCTL
|
|
|
|
/* echo control chars as ^(Char) */
|
|
|
|
.It Dv ISIG
|
|
|
|
/* enable signals
|
|
|
|
.Dv INTR ,
|
|
|
|
.Dv QUIT ,
|
|
|
|
.Dv [D]SUSP
|
|
|
|
*/
|
|
|
|
.It Dv ICANON
|
|
|
|
/* canonicalize input lines */
|
|
|
|
.It Dv ALTWERASE
|
|
|
|
/* use alternate
|
|
|
|
.Dv WERASE
|
|
|
|
algorithm */
|
|
|
|
.It Dv IEXTEN
|
|
|
|
/* enable
|
|
|
|
.Dv DISCARD
|
|
|
|
and
|
|
|
|
.Dv LNEXT
|
|
|
|
*/
|
|
|
|
.It Dv EXTPROC
|
|
|
|
/* external processing */
|
|
|
|
.It Dv TOSTOP
|
|
|
|
/* stop background jobs from output */
|
|
|
|
.It Dv FLUSHO
|
|
|
|
/* output being flushed (state) */
|
|
|
|
.It Dv NOKERNINFO
|
|
|
|
/* no kernel output from
|
|
|
|
.Dv VSTATUS
|
|
|
|
*/
|
|
|
|
.It Dv PENDIN
|
|
|
|
/* XXX retype pending input (state) */
|
|
|
|
.It Dv NOFLSH
|
|
|
|
/* don't flush after interrupt */
|
|
|
|
.El
|
|
|
|
.Pp
|
|
|
|
If
|
|
|
|
.Dv ECHO
|
2003-06-28 23:53:39 +00:00
|
|
|
is set, input characters are echoed back to the terminal.
|
|
|
|
If
|
1994-05-30 19:09:18 +00:00
|
|
|
.Dv ECHO
|
|
|
|
is not set, input characters are not echoed.
|
|
|
|
.Pp
|
|
|
|
If
|
|
|
|
.Dv ECHOE
|
|
|
|
and
|
|
|
|
.Dv ICANON
|
|
|
|
are set, the
|
|
|
|
.Dv ERASE
|
|
|
|
character causes the terminal
|
|
|
|
to erase the last character in the current line from the display, if
|
2003-06-28 23:53:39 +00:00
|
|
|
possible.
|
|
|
|
If there is no character to erase, an implementation may echo
|
1994-05-30 19:09:18 +00:00
|
|
|
an indication that this was the case or do nothing.
|
|
|
|
.Pp
|
|
|
|
If
|
|
|
|
.Dv ECHOK
|
|
|
|
and
|
|
|
|
.Dv ICANON
|
|
|
|
are set, the
|
|
|
|
.Dv KILL
|
|
|
|
character causes
|
|
|
|
the current line to be discarded and the system echoes the
|
|
|
|
.Ql \&\en
|
|
|
|
character after the
|
|
|
|
.Dv KILL
|
|
|
|
character.
|
|
|
|
.Pp
|
|
|
|
If
|
|
|
|
.Dv ECHOKE
|
|
|
|
and
|
|
|
|
.Dv ICANON
|
|
|
|
are set, the
|
|
|
|
.Dv KILL
|
|
|
|
character causes
|
|
|
|
the current line to be discarded and the system causes
|
|
|
|
the terminal
|
|
|
|
to erase the line from the display.
|
|
|
|
.Pp
|
|
|
|
If
|
|
|
|
.Dv ECHOPRT
|
|
|
|
and
|
|
|
|
.Dv ICANON
|
|
|
|
are set, the system assumes
|
|
|
|
that the display is a printing device and prints a
|
|
|
|
backslash and the erased characters when processing
|
|
|
|
.Dv ERASE
|
|
|
|
characters, followed by a forward slash.
|
|
|
|
.Pp
|
|
|
|
If
|
|
|
|
.Dv ECHOCTL
|
|
|
|
is set, the system echoes control characters
|
|
|
|
in a visible fashion using a caret followed by the control character.
|
|
|
|
.Pp
|
|
|
|
If
|
|
|
|
.Dv ALTWERASE
|
|
|
|
is set, the system uses an alternative algorithm
|
|
|
|
for determining what constitutes a word when processing
|
|
|
|
.Dv WERASE
|
|
|
|
characters (see
|
|
|
|
.Dv WERASE ) .
|
|
|
|
.Pp
|
|
|
|
If
|
|
|
|
.Dv ECHONL
|
|
|
|
and
|
|
|
|
.Dv ICANON
|
|
|
|
are set, the
|
|
|
|
.Ql \&\en
|
|
|
|
character echoes even if
|
|
|
|
.Dv ECHO
|
|
|
|
is not set.
|
|
|
|
.Pp
|
|
|
|
If
|
|
|
|
.Dv ICANON
|
2003-06-28 23:53:39 +00:00
|
|
|
is set, canonical processing is enabled.
|
|
|
|
This enables the
|
1994-05-30 19:09:18 +00:00
|
|
|
erase and kill edit functions, and the assembly of input characters into
|
|
|
|
lines delimited by
|
2001-02-01 16:38:02 +00:00
|
|
|
.Dv NL ,
|
1994-05-30 19:09:18 +00:00
|
|
|
.Dv EOF ,
|
|
|
|
and
|
2001-02-01 16:38:02 +00:00
|
|
|
.Dv EOL ,
|
1994-05-30 19:09:18 +00:00
|
|
|
as described in
|
|
|
|
.Sx "Canonical Mode Input Processing" .
|
|
|
|
.Pp
|
|
|
|
If
|
|
|
|
.Dv ICANON
|
|
|
|
is not set, read requests are satisfied directly from the input
|
2003-06-28 23:53:39 +00:00
|
|
|
queue.
|
|
|
|
A read is not satisfied until at least
|
1997-03-18 07:17:22 +00:00
|
|
|
.Dv MIN
|
1994-05-30 19:09:18 +00:00
|
|
|
bytes have been
|
|
|
|
received or the timeout value
|
1997-03-18 07:17:22 +00:00
|
|
|
.Dv TIME
|
2003-06-28 23:53:39 +00:00
|
|
|
expired between bytes.
|
|
|
|
The time value
|
2004-07-03 18:29:24 +00:00
|
|
|
represents tenths of seconds.
|
|
|
|
See
|
1994-05-30 19:09:18 +00:00
|
|
|
.Sx "Noncanonical Mode Input Processing"
|
|
|
|
for more details.
|
|
|
|
.Pp
|
|
|
|
If
|
|
|
|
.Dv ISIG
|
|
|
|
is set, each input character is checked against the special
|
|
|
|
control characters
|
|
|
|
.Dv INTR ,
|
|
|
|
.Dv QUIT ,
|
|
|
|
and
|
|
|
|
.Dv SUSP
|
2003-06-28 23:53:39 +00:00
|
|
|
(job control only).
|
|
|
|
If an input
|
1994-05-30 19:09:18 +00:00
|
|
|
character matches one of these control characters, the function
|
2003-06-28 23:53:39 +00:00
|
|
|
associated with that character is performed.
|
|
|
|
If
|
1994-05-30 19:09:18 +00:00
|
|
|
.Dv ISIG
|
|
|
|
is not set, no
|
2003-06-28 23:53:39 +00:00
|
|
|
checking is done.
|
|
|
|
Thus these special input functions are possible only
|
1994-05-30 19:09:18 +00:00
|
|
|
if
|
|
|
|
.Dv ISIG
|
|
|
|
is set.
|
|
|
|
.Pp
|
|
|
|
If
|
|
|
|
.Dv IEXTEN
|
|
|
|
is set, implementation-defined functions are recognized
|
2003-06-28 23:53:39 +00:00
|
|
|
from the input data.
|
|
|
|
How
|
1994-05-30 19:09:18 +00:00
|
|
|
.Dv IEXTEN
|
|
|
|
being set
|
|
|
|
interacts with
|
|
|
|
.Dv ICANON ,
|
|
|
|
.Dv ISIG ,
|
|
|
|
.Dv IXON ,
|
|
|
|
or
|
|
|
|
.Dv IXOFF
|
|
|
|
is implementation defined.
|
|
|
|
If
|
|
|
|
.Dv IEXTEN
|
|
|
|
is not set, then
|
|
|
|
implementation-defined functions are not recognized, and the
|
|
|
|
corresponding input characters are not processed as described for
|
|
|
|
.Dv ICANON ,
|
|
|
|
.Dv ISIG ,
|
|
|
|
.Dv IXON ,
|
|
|
|
and
|
|
|
|
.Dv IXOFF .
|
|
|
|
.Pp
|
|
|
|
If
|
|
|
|
.Dv NOFLSH
|
|
|
|
is set, the normal flush of the input and output queues
|
|
|
|
associated with the
|
|
|
|
.Dv INTR ,
|
|
|
|
.Dv QUIT ,
|
|
|
|
and
|
|
|
|
.Dv SUSP
|
|
|
|
characters
|
|
|
|
are not be done.
|
|
|
|
.Pp
|
|
|
|
If
|
|
|
|
.Dv TOSTOP
|
|
|
|
is set, the signal
|
|
|
|
.Dv SIGTTOU
|
|
|
|
is sent to the process group of a process that tries to write to
|
|
|
|
its controlling terminal if it is not in the foreground process group for
|
2003-06-28 23:53:39 +00:00
|
|
|
that terminal.
|
|
|
|
This signal, by default, stops the members of the process group.
|
|
|
|
Otherwise, the output generated by that process is output to the
|
|
|
|
current output stream.
|
|
|
|
Processes that are blocking or ignoring
|
1994-05-30 19:09:18 +00:00
|
|
|
.Dv SIGTTOU
|
|
|
|
signals are excepted and allowed to produce output and the
|
|
|
|
.Dv SIGTTOU
|
|
|
|
signal
|
|
|
|
is not sent.
|
|
|
|
.Pp
|
|
|
|
If
|
|
|
|
.Dv NOKERNINFO
|
|
|
|
is set, the kernel does not produce a status message
|
|
|
|
when processing
|
|
|
|
.Dv STATUS
|
|
|
|
characters (see
|
|
|
|
.Dv STATUS ) .
|
|
|
|
.Ss Special Control Characters
|
|
|
|
The special control characters values are defined by the array
|
|
|
|
.Fa c_cc .
|
|
|
|
This table lists the array index, the corresponding special character,
|
2003-06-28 23:53:39 +00:00
|
|
|
and the system default value.
|
|
|
|
For an accurate list of
|
1994-05-30 19:09:18 +00:00
|
|
|
the system defaults, consult the header file
|
2008-05-13 21:51:02 +00:00
|
|
|
.In sys/ttydefaults.h .
|
1994-05-30 19:09:18 +00:00
|
|
|
.Pp
|
|
|
|
.Bl -column "Index Name" "Special Character" -offset indent -compact
|
|
|
|
.It Em "Index Name Special Character Default Value"
|
|
|
|
.It Dv VEOF Ta EOF Ta \&^D
|
|
|
|
.It Dv VEOL Ta EOL Ta _POSIX_VDISABLE
|
|
|
|
.It Dv VEOL2 Ta EOL2 Ta _POSIX_VDISABLE
|
|
|
|
.It Dv VERASE Ta ERASE Ta \&^? Ql \&\e177
|
2004-07-03 18:29:24 +00:00
|
|
|
.It Dv VWERASE Ta WERASE Ta \&^W
|
1994-05-30 19:09:18 +00:00
|
|
|
.It Dv VKILL Ta KILL Ta \&^U
|
|
|
|
.It Dv VREPRINT Ta REPRINT Ta \&^R
|
|
|
|
.It Dv VINTR Ta INTR Ta \&^C
|
|
|
|
.It Dv VQUIT Ta QUIT Ta \&^\e\e Ql \&\e34
|
|
|
|
.It Dv VSUSP Ta SUSP Ta \&^Z
|
|
|
|
.It Dv VDSUSP Ta DSUSP Ta \&^Y
|
|
|
|
.It Dv VSTART Ta START Ta \&^Q
|
|
|
|
.It Dv VSTOP Ta STOP Ta \&^S
|
|
|
|
.It Dv VLNEXT Ta LNEXT Ta \&^V
|
|
|
|
.It Dv VDISCARD Ta DISCARD Ta \&^O
|
|
|
|
.It Dv VMIN Ta --- Ta \&1
|
|
|
|
.It Dv VTIME Ta --- Ta \&0
|
|
|
|
.It Dv VSTATUS Ta STATUS Ta \&^T
|
|
|
|
.El
|
|
|
|
.Pp
|
|
|
|
If the
|
|
|
|
value of one of the changeable special control characters (see
|
|
|
|
.Sx "Special Characters" )
|
|
|
|
is
|
|
|
|
.Dv {_POSIX_VDISABLE} ,
|
|
|
|
that function is disabled; that is, no input
|
|
|
|
data is recognized as the disabled special character.
|
|
|
|
If
|
|
|
|
.Dv ICANON
|
|
|
|
is
|
|
|
|
not set, the value of
|
|
|
|
.Dv {_POSIX_VDISABLE}
|
|
|
|
has no special meaning for the
|
|
|
|
.Dv VMIN
|
|
|
|
and
|
|
|
|
.Dv VTIME
|
|
|
|
entries of the
|
|
|
|
.Fa c_cc
|
|
|
|
array.
|
|
|
|
.Pp
|
|
|
|
The initial values of the flags and control characters
|
2001-07-14 19:41:16 +00:00
|
|
|
after
|
1996-04-08 04:18:31 +00:00
|
|
|
.Fn open
|
|
|
|
is set according to
|
1994-05-30 19:09:18 +00:00
|
|
|
the values in the header
|
2003-09-08 19:57:22 +00:00
|
|
|
.In sys/ttydefaults.h .
|
2009-12-28 09:26:46 +00:00
|
|
|
.Sh SEE ALSO
|
|
|
|
.Xr stty 1 ,
|
|
|
|
.Xr tcgetsid 3 ,
|
|
|
|
.Xr tcsendbreak 3 ,
|
|
|
|
.Xr tcsetattr 3 ,
|
|
|
|
.Xr tcsetsid 3 ,
|
2020-06-27 16:31:04 +00:00
|
|
|
.Xr tty 4 ,
|
|
|
|
.Xr stack 9
|