928 lines
22 KiB
HTML
928 lines
22 KiB
HTML
|
|
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
|
|
<HTML><HEAD><TITLE>Man page of IOCTL_TTY</TITLE>
|
|
</HEAD><BODY>
|
|
<H1>IOCTL_TTY</H1>
|
|
Section: Linux Programmer's Manual (2)<BR>Updated: 2017-09-15<BR><A HREF="#index">Index</A>
|
|
<A HREF="/cgi-bin/man/man2html">Return to Main Contents</A><HR>
|
|
|
|
<A NAME="lbAB"> </A>
|
|
<H2>NAME</H2>
|
|
|
|
ioctl_tty - ioctls for terminals and serial lines
|
|
<A NAME="lbAC"> </A>
|
|
<H2>SYNOPSIS</H2>
|
|
|
|
<B>#include <<A HREF="file:///usr/include/termios.h">termios.h</A>></B>
|
|
|
|
<P>
|
|
|
|
<B>int ioctl(int </B><I>fd</I><B>, int </B><I>cmd</I><B>, ...);</B>
|
|
|
|
<A NAME="lbAD"> </A>
|
|
<H2>DESCRIPTION</H2>
|
|
|
|
The
|
|
<B><A HREF="/cgi-bin/man/man2html?2+ioctl">ioctl</A></B>(2)
|
|
|
|
call for terminals and serial ports accepts many possible command arguments.
|
|
Most require a third argument, of varying type, here called
|
|
<I>argp</I>
|
|
|
|
or
|
|
<I>arg</I>.
|
|
|
|
<P>
|
|
|
|
Use of
|
|
<I>ioctl</I>
|
|
|
|
makes for nonportable programs.
|
|
Use the POSIX interface described in
|
|
<B><A HREF="/cgi-bin/man/man2html?3+termios">termios</A></B>(3)
|
|
|
|
whenever possible.
|
|
<A NAME="lbAE"> </A>
|
|
<H3>Get and set terminal attributes</H3>
|
|
|
|
<DL COMPACT>
|
|
<DT id="1"><B>TCGETS<TT> </TT>struct termios *</B><I>argp</I>
|
|
|
|
<DD>
|
|
Equivalent to<BR>
|
|
<I>tcgetattr(fd, argp)</I>.
|
|
|
|
<BR>
|
|
|
|
Get the current serial port settings.
|
|
<DT id="2"><B>TCSETS<TT> </TT>const struct termios *</B><I>argp</I>
|
|
|
|
<DD>
|
|
Equivalent to<BR>
|
|
<I>tcsetattr(fd, TCSANOW, argp)</I>.
|
|
|
|
<BR>
|
|
|
|
Set the current serial port settings.
|
|
<DT id="3"><B>TCSETSW<TT> </TT>const struct termios *</B><I>argp</I>
|
|
|
|
<DD>
|
|
Equivalent to<BR>
|
|
<I>tcsetattr(fd, TCSADRAIN, argp)</I>.
|
|
|
|
<BR>
|
|
|
|
Allow the output buffer to drain, and
|
|
set the current serial port settings.
|
|
<DT id="4"><B>TCSETSF<TT> </TT>const struct termios *</B><I>argp</I>
|
|
|
|
<DD>
|
|
Equivalent to<BR>
|
|
<I>tcsetattr(fd, TCSAFLUSH, argp)</I>.
|
|
|
|
<BR>
|
|
|
|
Allow the output buffer to drain, discard pending input, and
|
|
set the current serial port settings.
|
|
</DL>
|
|
<P>
|
|
|
|
The following four ioctls are just like
|
|
<B>TCGETS</B>,
|
|
|
|
<B>TCSETS</B>,
|
|
|
|
<B>TCSETSW</B>,
|
|
|
|
<B>TCSETSF</B>,
|
|
|
|
except that they take a
|
|
<I>struct termio *</I>
|
|
|
|
instead of a
|
|
<I>struct termios *</I>.
|
|
|
|
<DL COMPACT>
|
|
<DT id="5"><DD>
|
|
<B>TCGETA<TT> </TT>struct termio *</B><I>argp</I>
|
|
|
|
<DT id="6"><DD>
|
|
<B>TCSETA<TT> </TT>const struct termio *</B><I>argp</I>
|
|
|
|
<DT id="7"><DD>
|
|
<B>TCSETAW<TT> </TT>const struct termio *</B><I>argp</I>
|
|
|
|
<DT id="8"><DD>
|
|
<B>TCSETAF<TT> </TT>const struct termio *</B><I>argp</I>
|
|
|
|
</DL>
|
|
<A NAME="lbAF"> </A>
|
|
<H3>Locking the termios structure</H3>
|
|
|
|
The<BR>
|
|
<I>termios</I>
|
|
|
|
structure of a terminal can be locked.
|
|
The lock is itself a
|
|
<I>termios</I>
|
|
|
|
structure, with nonzero bits or fields indicating a
|
|
locked value.
|
|
<DL COMPACT>
|
|
<DT id="9"><B>TIOCGLCKTRMIOS<TT> </TT>struct termios *</B><I>argp</I>
|
|
|
|
<DD>
|
|
Gets the locking status of the<BR>
|
|
<I>termios</I>
|
|
|
|
structure of the terminal.
|
|
<DT id="10"><B>TIOCSLCKTRMIOS<TT> </TT>const struct termios *</B><I>argp</I>
|
|
|
|
<DD>
|
|
Sets the locking status of the<BR>
|
|
<I>termios</I>
|
|
|
|
structure of the terminal.
|
|
Only a process with the
|
|
<B>CAP_SYS_ADMIN</B>
|
|
|
|
capability can do this.
|
|
</DL>
|
|
<A NAME="lbAG"> </A>
|
|
<H3>Get and set window size</H3>
|
|
|
|
Window sizes are kept in the kernel, but not used by the kernel
|
|
(except in the case of virtual consoles, where the kernel will
|
|
update the window size when the size of the virtual console changes,
|
|
for example, by loading a new font).
|
|
<P>
|
|
|
|
The following constants and structure are defined in
|
|
<I><<A HREF="file:///usr/include/sys/ioctl.h">sys/ioctl.h</A>></I>.
|
|
|
|
<DL COMPACT>
|
|
<DT id="11"><B>TIOCGWINSZ<TT> </TT>struct winsize *</B><I>argp</I>
|
|
|
|
<DD>
|
|
Get window size.<BR>
|
|
<DT id="12"><B>TIOCSWINSZ<TT> </TT>const struct winsize *</B><I>argp</I>
|
|
|
|
<DD>
|
|
Set window size.<BR>
|
|
</DL>
|
|
<P>
|
|
|
|
The struct used by these ioctls is defined as
|
|
<P>
|
|
|
|
|
|
|
|
struct winsize {
|
|
<BR> unsigned short ws_row;
|
|
<BR> unsigned short ws_col;
|
|
<BR> unsigned short ws_xpixel; /* unused */
|
|
<BR> unsigned short ws_ypixel; /* unused */
|
|
};
|
|
|
|
|
|
<P>
|
|
|
|
When the window size changes, a
|
|
<B>SIGWINCH</B>
|
|
|
|
signal is sent to the
|
|
foreground process group.
|
|
<A NAME="lbAH"> </A>
|
|
<H3>Sending a break</H3>
|
|
|
|
<DL COMPACT>
|
|
<DT id="13"><B>TCSBRK<TT> </TT>int </B><I>arg</I>
|
|
|
|
<DD>
|
|
Equivalent to<BR>
|
|
<I>tcsendbreak(fd, arg)</I>.
|
|
|
|
<BR>
|
|
|
|
If the terminal is using asynchronous serial data transmission, and
|
|
<I>arg</I>
|
|
|
|
is zero, then send a break (a stream of zero bits) for between
|
|
0.25 and 0.5 seconds.
|
|
If the terminal is not using asynchronous
|
|
serial data transmission, then either a break is sent, or the function
|
|
returns without doing anything.
|
|
When
|
|
<I>arg</I>
|
|
|
|
is nonzero, nobody knows what will happen.
|
|
<DT id="14"><DD>
|
|
(SVr4, UnixWare, Solaris, Linux treat
|
|
<I>tcsendbreak(fd,arg)</I>
|
|
|
|
with nonzero
|
|
<I>arg</I>
|
|
|
|
like
|
|
<I>tcdrain(fd)</I>.
|
|
|
|
SunOS treats
|
|
<I>arg</I>
|
|
|
|
as a multiplier, and sends a stream of bits
|
|
<I>arg</I>
|
|
|
|
times as long as done for zero
|
|
<I>arg</I>.
|
|
|
|
DG/UX and AIX treat
|
|
<I>arg</I>
|
|
|
|
(when nonzero) as a time interval measured in milliseconds.
|
|
HP-UX ignores
|
|
<I>arg</I>.)
|
|
|
|
<DT id="15"><B>TCSBRKP<TT> </TT>int </B><I>arg</I>
|
|
|
|
<DD>
|
|
So-called "POSIX version" of<BR>
|
|
<B>TCSBRK</B>.
|
|
|
|
It treats nonzero
|
|
<I>arg</I>
|
|
|
|
as a timeinterval measured in deciseconds, and does nothing
|
|
when the driver does not support breaks.
|
|
<DT id="16"><B>TIOCSBRK<TT> </TT>void</B>
|
|
|
|
<DD>
|
|
Turn break on, that is, start sending zero bits.<BR>
|
|
<DT id="17"><B>TIOCCBRK<TT> </TT>void</B>
|
|
|
|
<DD>
|
|
Turn break off, that is, stop sending zero bits.<BR>
|
|
</DL>
|
|
<A NAME="lbAI"> </A>
|
|
<H3>Software flow control</H3>
|
|
|
|
<DL COMPACT>
|
|
<DT id="18"><B>TCXONC<TT> </TT>int </B><I>arg</I>
|
|
|
|
<DD>
|
|
Equivalent to<BR>
|
|
<I>tcflow(fd, arg)</I>.
|
|
|
|
<BR>
|
|
|
|
See
|
|
<B><A HREF="/cgi-bin/man/man2html?3+tcflow">tcflow</A></B>(3)
|
|
|
|
for the argument values
|
|
<B>TCOOFF</B>,
|
|
|
|
<B>TCOON</B>,
|
|
|
|
<B>TCIOFF</B>,
|
|
|
|
<B>TCION</B>.
|
|
|
|
</DL>
|
|
<A NAME="lbAJ"> </A>
|
|
<H3>Buffer count and flushing</H3>
|
|
|
|
<DL COMPACT>
|
|
<DT id="19"><B>FIONREAD<TT> </TT>int *</B><I>argp</I>
|
|
|
|
<DD>
|
|
Get the number of bytes in the input buffer.<BR>
|
|
<DT id="20"><B>TIOCINQ<TT> </TT>int *</B><I>argp</I>
|
|
|
|
<DD>
|
|
Same as<BR>
|
|
<B>FIONREAD</B>.
|
|
|
|
<DT id="21"><B>TIOCOUTQ<TT> </TT>int *</B><I>argp</I>
|
|
|
|
<DD>
|
|
Get the number of bytes in the output buffer.<BR>
|
|
<DT id="22"><B>TCFLSH<TT> </TT>int </B><I>arg</I>
|
|
|
|
<DD>
|
|
Equivalent to<BR>
|
|
<I>tcflush(fd, arg)</I>.
|
|
|
|
<BR>
|
|
|
|
See
|
|
<B><A HREF="/cgi-bin/man/man2html?3+tcflush">tcflush</A></B>(3)
|
|
|
|
for the argument values
|
|
<B>TCIFLUSH</B>,
|
|
|
|
<B>TCOFLUSH</B>,
|
|
|
|
<B>TCIOFLUSH</B>.
|
|
|
|
</DL>
|
|
<A NAME="lbAK"> </A>
|
|
<H3>Faking input</H3>
|
|
|
|
<DL COMPACT>
|
|
<DT id="23"><B>TIOCSTI<TT> </TT>const char *</B><I>argp</I>
|
|
|
|
<DD>
|
|
Insert the given byte in the input queue.<BR>
|
|
</DL>
|
|
<A NAME="lbAL"> </A>
|
|
<H3>Redirecting console output</H3>
|
|
|
|
<DL COMPACT>
|
|
<DT id="24"><B>TIOCCONS<TT> </TT>void</B>
|
|
|
|
<DD>
|
|
Redirect output that would have gone to<BR>
|
|
<I>/dev/console</I>
|
|
|
|
or
|
|
<I>/dev/tty0</I>
|
|
|
|
to the given terminal.
|
|
If that was a pseudoterminal master, send it to the slave.
|
|
In Linux before version 2.6.10,
|
|
anybody can do this as long as the output was not redirected yet;
|
|
since version 2.6.10, only a process with the
|
|
<B>CAP_SYS_ADMIN</B>
|
|
|
|
capability may do this.
|
|
If output was redirected already
|
|
<B>EBUSY</B>
|
|
|
|
is returned,
|
|
but redirection can be stopped by using this ioctl with
|
|
<I>fd</I>
|
|
|
|
pointing at
|
|
<I>/dev/console</I>
|
|
|
|
or
|
|
<I>/dev/tty0</I>.
|
|
|
|
</DL>
|
|
<A NAME="lbAM"> </A>
|
|
<H3>Controlling terminal</H3>
|
|
|
|
<DL COMPACT>
|
|
<DT id="25"><B>TIOCSCTTY<TT> </TT>int </B><I>arg</I>
|
|
|
|
<DD>
|
|
Make the given terminal the controlling terminal of the calling process.<BR>
|
|
The calling process must be a session leader and not have a
|
|
controlling terminal already.
|
|
For this case,
|
|
<I>arg</I>
|
|
|
|
should be specified as zero.
|
|
<DT id="26"><DD>
|
|
If this terminal is already the controlling terminal
|
|
of a different session group, then the ioctl fails with
|
|
<B>EPERM</B>,
|
|
|
|
unless the caller has the
|
|
<B>CAP_SYS_ADMIN</B>
|
|
|
|
capability and
|
|
<I>arg</I>
|
|
|
|
equals 1, in which case the terminal is stolen, and all processes that had
|
|
it as controlling terminal lose it.
|
|
<DT id="27"><B>TIOCNOTTY<TT> </TT>void</B>
|
|
|
|
<DD>
|
|
If the given terminal was the controlling terminal of the calling process,<BR>
|
|
give up this controlling terminal.
|
|
If the process was session leader,
|
|
then send
|
|
<B>SIGHUP</B>
|
|
|
|
and
|
|
<B>SIGCONT</B>
|
|
|
|
to the foreground process group
|
|
and all processes in the current session lose their controlling terminal.
|
|
</DL>
|
|
<A NAME="lbAN"> </A>
|
|
<H3>Process group and session ID</H3>
|
|
|
|
<DL COMPACT>
|
|
<DT id="28"><B>TIOCGPGRP<TT> </TT>pid_t *</B><I>argp</I>
|
|
|
|
<DD>
|
|
When successful, equivalent to<BR>
|
|
<I>*argp = tcgetpgrp(fd)</I>.
|
|
|
|
<BR>
|
|
|
|
Get the process group ID of the foreground process group on this terminal.
|
|
<DT id="29"><B>TIOCSPGRP<TT> </TT>const pid_t *</B><I>argp</I>
|
|
|
|
<DD>
|
|
Equivalent to<BR>
|
|
<I>tcsetpgrp(fd, *argp)</I>.
|
|
|
|
<BR>
|
|
|
|
Set the foreground process group ID of this terminal.
|
|
<DT id="30"><B>TIOCGSID<TT> </TT>pid_t *</B><I>argp</I>
|
|
|
|
<DD>
|
|
Get the session ID of the given terminal.<BR>
|
|
This fails with the error
|
|
<B>ENOTTY</B>
|
|
|
|
if the terminal is not a master pseudoterminal
|
|
and not our controlling terminal.
|
|
Strange.
|
|
</DL>
|
|
<A NAME="lbAO"> </A>
|
|
<H3>Exclusive mode</H3>
|
|
|
|
<DL COMPACT>
|
|
<DT id="31"><B>TIOCEXCL<TT> </TT>void</B>
|
|
|
|
<DD>
|
|
Put the terminal into exclusive mode.<BR>
|
|
No further
|
|
<B><A HREF="/cgi-bin/man/man2html?2+open">open</A></B>(2)
|
|
|
|
operations on the terminal are permitted.
|
|
(They fail with
|
|
<B>EBUSY</B>,
|
|
|
|
except for a process with the
|
|
<B>CAP_SYS_ADMIN</B>
|
|
|
|
capability.)
|
|
<DT id="32"><B>TIOCGEXCL<TT> </TT>int *</B><I>argp</I>
|
|
|
|
<DD>
|
|
(since Linux 3.8)<BR>
|
|
If the terminal is currently in exclusive mode,
|
|
place a nonzero value in the location pointed to by
|
|
<I>argp</I>;
|
|
|
|
otherwise, place zero in
|
|
<I>*argp</I>.
|
|
|
|
<DT id="33"><B>TIOCNXCL<TT> </TT>void</B>
|
|
|
|
<DD>
|
|
Disable exclusive mode.<BR>
|
|
</DL>
|
|
<A NAME="lbAP"> </A>
|
|
<H3>Line discipline</H3>
|
|
|
|
<DL COMPACT>
|
|
<DT id="34"><B>TIOCGETD<TT> </TT>int *</B><I>argp</I>
|
|
|
|
<DD>
|
|
Get the line discipline of the terminal.<BR>
|
|
<DT id="35"><B>TIOCSETD<TT> </TT>const int *</B><I>argp</I>
|
|
|
|
<DD>
|
|
Set the line discipline of the terminal.<BR>
|
|
</DL>
|
|
<A NAME="lbAQ"> </A>
|
|
<H3>Pseudoterminal ioctls</H3>
|
|
|
|
<DL COMPACT>
|
|
<DT id="36"><B>TIOCPKT<TT> </TT>const int *</B><I>argp</I>
|
|
|
|
<DD>
|
|
Enable (when<BR>
|
|
*<I>argp</I>
|
|
|
|
is nonzero) or disable packet mode.
|
|
Can be applied to the master side of a pseudoterminal only (and will return
|
|
<B>ENOTTY</B>
|
|
|
|
otherwise).
|
|
In packet mode, each subsequent
|
|
<B><A HREF="/cgi-bin/man/man2html?2+read">read</A></B>(2)
|
|
|
|
will return a packet that either contains a single nonzero control byte,
|
|
or has a single byte containing zero (' ') followed by data
|
|
written on the slave side of the pseudoterminal.
|
|
If the first byte is not
|
|
<B>TIOCPKT_DATA</B>
|
|
|
|
(0), it is an OR of one
|
|
or more of the following bits:
|
|
<DT id="37"><DD>
|
|
<PRE>
|
|
TIOCPKT_FLUSHREAD The read queue for the terminal is flushed.
|
|
TIOCPKT_FLUSHWRITE The write queue for the terminal is flushed.
|
|
TIOCPKT_STOP Output to the terminal is stopped.
|
|
TIOCPKT_START Output to the terminal is restarted.
|
|
TIOCPKT_DOSTOP The start and stop characters are <B>^S</B>/<B>^Q</B>.
|
|
TIOCPKT_NOSTOP The start and stop characters are not <B>^S</B>/<B>^Q</B>.
|
|
</PRE>
|
|
|
|
<DT id="38"><DD>
|
|
While this mode is in use, the presence
|
|
of control status information to be read
|
|
from the master side may be detected by a
|
|
<B><A HREF="/cgi-bin/man/man2html?2+select">select</A></B>(2)
|
|
|
|
for exceptional conditions or a
|
|
<B><A HREF="/cgi-bin/man/man2html?2+poll">poll</A></B>(2)
|
|
|
|
for the
|
|
<I>POLLPRI</I>
|
|
|
|
event.
|
|
<DT id="39"><DD>
|
|
This mode is used by
|
|
<B><A HREF="/cgi-bin/man/man2html?1+rlogin">rlogin</A></B>(1)
|
|
|
|
and
|
|
<B><A HREF="/cgi-bin/man/man2html?8+rlogind">rlogind</A></B>(8)
|
|
|
|
to implement a remote-echoed,
|
|
locally <B>^S</B>/<B>^Q</B> flow-controlled remote login.
|
|
<DT id="40"><B>TIOCGPKT<TT> </TT>const int *</B><I>argp</I>
|
|
|
|
<DD>
|
|
(since Linux 3.8)<BR>
|
|
Return the current packet mode setting in the integer pointed to by
|
|
<I>argp</I>.
|
|
|
|
<DT id="41"><B>TIOCSPTLCK<TT> </TT>int *</B><I>argp</I>
|
|
|
|
<DD>
|
|
Set (if<BR>
|
|
<I>*argp</I>
|
|
|
|
is nonzero) or remove (if
|
|
<I>*argp</I>
|
|
|
|
is zero) the pseudoterminal slave device.
|
|
(See also
|
|
<B><A HREF="/cgi-bin/man/man2html?3+unlockpt">unlockpt</A></B>(3).)
|
|
|
|
<DT id="42"><B>TIOCGPTLCK<TT> </TT>int *</B><I>argp</I>
|
|
|
|
<DD>
|
|
(since Linux 3.8)<BR>
|
|
Place the current lock state of the pseudoterminal slave device
|
|
in the location pointed to by
|
|
<I>argp</I>.
|
|
|
|
<DT id="43"><B>TIOCGPTPEER<TT> </TT>int </B><I>flags</I>
|
|
|
|
<DD>
|
|
|
|
(since Linux 4.13)<BR>
|
|
Given a file descriptor in
|
|
<I>fd</I>
|
|
|
|
that refers to a pseudoterminal master,
|
|
open (with the given
|
|
<B><A HREF="/cgi-bin/man/man2html?2+open">open</A></B>(2)-style
|
|
|
|
<I>flags</I>)
|
|
|
|
and return a new file descriptor that refers to the peer
|
|
pseudoterminal slave device.
|
|
This operation can be performed
|
|
regardless of whether the pathname of the slave device
|
|
is accessible through the calling process's mount namespace.
|
|
<DT id="44"><DD>
|
|
Security-conscious programs interacting with namespaces may wish to use this
|
|
operation rather than
|
|
<B><A HREF="/cgi-bin/man/man2html?2+open">open</A></B>(2)
|
|
|
|
with the pathname returned by
|
|
<B><A HREF="/cgi-bin/man/man2html?3+ptsname">ptsname</A></B>(3),
|
|
|
|
and similar library functions that have insecure APIs.
|
|
(For example, confusion can occur in some cases using
|
|
<B><A HREF="/cgi-bin/man/man2html?3+ptsname">ptsname</A></B>(3)
|
|
|
|
with a pathname where a devpts filesystem
|
|
has been mounted in a different mount namespace.)
|
|
</DL>
|
|
<P>
|
|
|
|
The BSD ioctls
|
|
<B>TIOCSTOP</B>,
|
|
|
|
<B>TIOCSTART</B>,
|
|
|
|
<B>TIOCUCNTL</B>,
|
|
|
|
<B>TIOCREMOTE</B>
|
|
|
|
have not been implemented under Linux.
|
|
<A NAME="lbAR"> </A>
|
|
<H3>Modem control</H3>
|
|
|
|
<DL COMPACT>
|
|
<DT id="45"><B>TIOCMGET<TT> </TT>int *</B><I>argp</I>
|
|
|
|
<DD>
|
|
Get the status of modem bits.<BR>
|
|
<DT id="46"><B>TIOCMSET<TT> </TT>const int *</B><I>argp</I>
|
|
|
|
<DD>
|
|
Set the status of modem bits.<BR>
|
|
<DT id="47"><B>TIOCMBIC<TT> </TT>const int *</B><I>argp</I>
|
|
|
|
<DD>
|
|
Clear the indicated modem bits.<BR>
|
|
<DT id="48"><B>TIOCMBIS<TT> </TT>const int *</B><I>argp</I>
|
|
|
|
<DD>
|
|
Set the indicated modem bits.<BR>
|
|
</DL>
|
|
<P>
|
|
|
|
The following bits are used by the above ioctls:
|
|
<P>
|
|
|
|
<PRE>
|
|
TIOCM_LE DSR (data set ready/line enable)
|
|
TIOCM_DTR DTR (data terminal ready)
|
|
TIOCM_RTS RTS (request to send)
|
|
TIOCM_ST Secondary TXD (transmit)
|
|
TIOCM_SR Secondary RXD (receive)
|
|
TIOCM_CTS CTS (clear to send)
|
|
TIOCM_CAR DCD (data carrier detect)
|
|
TIOCM_CD see TIOCM_CAR
|
|
TIOCM_RNG RNG (ring)
|
|
TIOCM_RI see TIOCM_RNG
|
|
TIOCM_DSR DSR (data set ready)
|
|
</PRE>
|
|
|
|
<DL COMPACT>
|
|
<DT id="49"><B>TIOCMIWAIT<TT> </TT>int </B><I>arg</I>
|
|
|
|
<DD>
|
|
Wait for any of the 4 modem bits (DCD, RI, DSR, CTS) to change.<BR>
|
|
The bits of interest are specified as a bit mask in
|
|
<I>arg</I>,
|
|
|
|
by ORing together any of the bit values,
|
|
<B>TIOCM_RNG</B>,
|
|
|
|
<B>TIOCM_DSR</B>,
|
|
|
|
<B>TIOCM_CD</B>,
|
|
|
|
and
|
|
<B>TIOCM_CTS</B>.
|
|
|
|
The caller should use
|
|
<B>TIOCGICOUNT</B>
|
|
|
|
to see which bit has changed.
|
|
<DT id="50"><B>TIOCGICOUNT<TT> </TT>struct serial_icounter_struct *</B><I>argp</I>
|
|
|
|
<DD>
|
|
Get counts of input serial line interrupts (DCD, RI, DSR, CTS).<BR>
|
|
The counts are written to the
|
|
<I>serial_icounter_struct</I>
|
|
|
|
structure pointed to by
|
|
<I>argp</I>.
|
|
|
|
<DT id="51"><DD>
|
|
Note: both 1->0 and 0->1 transitions are counted, except for
|
|
RI, where only 0->1 transitions are counted.
|
|
</DL>
|
|
<A NAME="lbAS"> </A>
|
|
<H3>Marking a line as local</H3>
|
|
|
|
<DL COMPACT>
|
|
<DT id="52"><B>TIOCGSOFTCAR<TT> </TT>int *</B><I>argp</I>
|
|
|
|
<DD>
|
|
("Get software carrier flag")<BR>
|
|
Get the status of the CLOCAL flag in the c_cflag field of the
|
|
<I>termios</I>
|
|
|
|
structure.
|
|
<DT id="53"><B>TIOCSSOFTCAR<TT> </TT>const int *</B><I>argp</I>
|
|
|
|
<DD>
|
|
("Set software carrier flag")<BR>
|
|
Set the CLOCAL flag in the
|
|
<I>termios</I>
|
|
|
|
structure when
|
|
*<I>argp</I>
|
|
|
|
is nonzero, and clear it otherwise.
|
|
</DL>
|
|
<P>
|
|
|
|
If the
|
|
<B>CLOCAL</B>
|
|
|
|
flag for a line is off, the hardware carrier detect (DCD)
|
|
signal is significant, and an
|
|
<B><A HREF="/cgi-bin/man/man2html?2+open">open</A></B>(2)
|
|
|
|
of the corresponding terminal will block until DCD is asserted,
|
|
unless the
|
|
<B>O_NONBLOCK</B>
|
|
|
|
flag is given.
|
|
If
|
|
<B>CLOCAL</B>
|
|
|
|
is set, the line behaves as if DCD is always asserted.
|
|
The software carrier flag is usually turned on for local devices,
|
|
and is off for lines with modems.
|
|
<A NAME="lbAT"> </A>
|
|
<H3>Linux-specific</H3>
|
|
|
|
For the
|
|
<B>TIOCLINUX</B>
|
|
|
|
ioctl, see
|
|
<B><A HREF="/cgi-bin/man/man2html?2+ioctl_console">ioctl_console</A></B>(2).
|
|
|
|
<A NAME="lbAU"> </A>
|
|
<H3>Kernel debugging</H3>
|
|
|
|
<B>#include <<A HREF="file:///usr/include/linux/tty.h">linux/tty.h</A>></B>
|
|
|
|
<DL COMPACT>
|
|
<DT id="54"><B>TIOCTTYGSTRUCT<TT> </TT>struct tty_struct *</B><I>argp</I>
|
|
|
|
<DD>
|
|
Get the<BR>
|
|
<I>tty_struct</I>
|
|
|
|
corresponding to
|
|
<I>fd</I>.
|
|
|
|
This command was removed in Linux 2.5.67.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
</DL>
|
|
<A NAME="lbAV"> </A>
|
|
<H2>RETURN VALUE</H2>
|
|
|
|
The
|
|
<B><A HREF="/cgi-bin/man/man2html?2+ioctl">ioctl</A></B>(2)
|
|
|
|
system call returns 0 on success.
|
|
On error, it returns -1 and sets
|
|
<I>errno</I>
|
|
|
|
appropriately.
|
|
<A NAME="lbAW"> </A>
|
|
<H2>ERRORS</H2>
|
|
|
|
<DL COMPACT>
|
|
<DT id="55"><B>EINVAL</B>
|
|
|
|
<DD>
|
|
Invalid command parameter.
|
|
<DT id="56"><B>ENOIOCTLCMD</B>
|
|
|
|
<DD>
|
|
Unknown command.
|
|
<DT id="57"><B>ENOTTY</B>
|
|
|
|
<DD>
|
|
Inappropriate
|
|
<I>fd</I>.
|
|
|
|
<DT id="58"><B>EPERM</B>
|
|
|
|
<DD>
|
|
Insufficient permission.
|
|
</DL>
|
|
<A NAME="lbAX"> </A>
|
|
<H2>EXAMPLE</H2>
|
|
|
|
Check the condition of DTR on the serial port.
|
|
<P>
|
|
|
|
|
|
#include <<A HREF="file:///usr/include/termios.h">termios.h</A>>
|
|
#include <<A HREF="file:///usr/include/fcntl.h">fcntl.h</A>>
|
|
#include <<A HREF="file:///usr/include/sys/ioctl.h">sys/ioctl.h</A>>
|
|
<P>
|
|
int
|
|
main(void)
|
|
{
|
|
<BR> int fd, serial;
|
|
<P>
|
|
<BR> fd = open("/dev/ttyS0", O_RDONLY);
|
|
<BR> ioctl(fd, TIOCMGET, &serial);
|
|
<BR> if (serial & TIOCM_DTR)
|
|
<BR> puts("TIOCM_DTR is set");
|
|
<BR> else
|
|
<BR> puts("TIOCM_DTR is not set");
|
|
<BR> close(fd);
|
|
}
|
|
|
|
<A NAME="lbAY"> </A>
|
|
<H2>SEE ALSO</H2>
|
|
|
|
<B><A HREF="/cgi-bin/man/man2html?1+ldattach">ldattach</A></B>(1),
|
|
|
|
<B><A HREF="/cgi-bin/man/man2html?2+ioctl">ioctl</A></B>(2),
|
|
|
|
<B><A HREF="/cgi-bin/man/man2html?2+ioctl_console">ioctl_console</A></B>(2),
|
|
|
|
<B><A HREF="/cgi-bin/man/man2html?3+termios">termios</A></B>(3),
|
|
|
|
<B><A HREF="/cgi-bin/man/man2html?7+pty">pty</A></B>(7)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<A NAME="lbAZ"> </A>
|
|
<H2>COLOPHON</H2>
|
|
|
|
This page is part of release 5.05 of the Linux
|
|
<I>man-pages</I>
|
|
|
|
project.
|
|
A description of the project,
|
|
information about reporting bugs,
|
|
and the latest version of this page,
|
|
can be found at
|
|
<A HREF="https://www.kernel.org/doc/man-pages/.">https://www.kernel.org/doc/man-pages/.</A>
|
|
<P>
|
|
|
|
<HR>
|
|
<A NAME="index"> </A><H2>Index</H2>
|
|
<DL>
|
|
<DT id="59"><A HREF="#lbAB">NAME</A><DD>
|
|
<DT id="60"><A HREF="#lbAC">SYNOPSIS</A><DD>
|
|
<DT id="61"><A HREF="#lbAD">DESCRIPTION</A><DD>
|
|
<DL>
|
|
<DT id="62"><A HREF="#lbAE">Get and set terminal attributes</A><DD>
|
|
<DT id="63"><A HREF="#lbAF">Locking the termios structure</A><DD>
|
|
<DT id="64"><A HREF="#lbAG">Get and set window size</A><DD>
|
|
<DT id="65"><A HREF="#lbAH">Sending a break</A><DD>
|
|
<DT id="66"><A HREF="#lbAI">Software flow control</A><DD>
|
|
<DT id="67"><A HREF="#lbAJ">Buffer count and flushing</A><DD>
|
|
<DT id="68"><A HREF="#lbAK">Faking input</A><DD>
|
|
<DT id="69"><A HREF="#lbAL">Redirecting console output</A><DD>
|
|
<DT id="70"><A HREF="#lbAM">Controlling terminal</A><DD>
|
|
<DT id="71"><A HREF="#lbAN">Process group and session ID</A><DD>
|
|
<DT id="72"><A HREF="#lbAO">Exclusive mode</A><DD>
|
|
<DT id="73"><A HREF="#lbAP">Line discipline</A><DD>
|
|
<DT id="74"><A HREF="#lbAQ">Pseudoterminal ioctls</A><DD>
|
|
<DT id="75"><A HREF="#lbAR">Modem control</A><DD>
|
|
<DT id="76"><A HREF="#lbAS">Marking a line as local</A><DD>
|
|
<DT id="77"><A HREF="#lbAT">Linux-specific</A><DD>
|
|
<DT id="78"><A HREF="#lbAU">Kernel debugging</A><DD>
|
|
</DL>
|
|
<DT id="79"><A HREF="#lbAV">RETURN VALUE</A><DD>
|
|
<DT id="80"><A HREF="#lbAW">ERRORS</A><DD>
|
|
<DT id="81"><A HREF="#lbAX">EXAMPLE</A><DD>
|
|
<DT id="82"><A HREF="#lbAY">SEE ALSO</A><DD>
|
|
<DT id="83"><A HREF="#lbAZ">COLOPHON</A><DD>
|
|
</DL>
|
|
<HR>
|
|
This document was created by
|
|
<A HREF="/cgi-bin/man/man2html">man2html</A>,
|
|
using the manual pages.<BR>
|
|
Time: 00:05:33 GMT, March 31, 2021
|
|
</BODY>
|
|
</HTML>
|