| 1 |
'\" t |
| 2 |
.\" Copyright 2002, Walter Harms <[email protected]> |
| 3 |
.\" Copyright 2002, Andries E. Brouwer <[email protected]> |
| 4 |
.\" Copyright, the authors of the Linux man-pages project |
| 5 |
.\" |
| 6 |
.\" SPDX-License-Identifier: GPL-1.0-or-later |
| 7 |
.\" |
| 8 |
.TH TIOCPKT 2const 2026-02-08 "Linux man-pages 6.18" |
| 9 |
.SH NAME |
| 10 |
TIOCPKT, |
| 11 |
TIOCGPKT, |
| 12 |
TIOCSPTLCK, |
| 13 |
TIOCGPTLCK, |
| 14 |
TIOCGPTPEER |
| 15 |
\- |
| 16 |
pseudoterminal ioctls |
| 17 |
.SH LIBRARY |
| 18 |
Standard C library |
| 19 |
.RI ( libc ,\~ \-lc ) |
| 20 |
.SH SYNOPSIS |
| 21 |
.nf |
| 22 |
.BR "#include <asm/termbits.h>" " /* Definition of " TIOC* " constants */" |
| 23 |
.B #include <sys/ioctl.h> |
| 24 |
.P |
| 25 |
.BI "int ioctl(int " fd ", TIOCPKT, const int *" mode ); |
| 26 |
.BI "int ioctl(int " fd ", TIOCPKT, int *" mode ); |
| 27 |
.P |
| 28 |
.BI "int ioctl(int " fd ", TIOCSPTLCK, const int *" lock ); |
| 29 |
.BI "int ioctl(int " fd ", TIOCGPTLCK, int *" lock ); |
| 30 |
.P |
| 31 |
.BI "int ioctl(int " fd ", TIOCGPTPEER, int " flags ); |
| 32 |
.fi |
| 33 |
.SH DESCRIPTION |
| 34 |
.TP |
| 35 |
.B TIOCPKT |
| 36 |
Enable (when |
| 37 |
.RI * mode |
| 38 |
is nonzero) or disable packet mode. |
| 39 |
Can be applied to the master side of a pseudoterminal only (and will return |
| 40 |
.B ENOTTY |
| 41 |
otherwise). |
| 42 |
In packet mode, each subsequent |
| 43 |
.BR read (2) |
| 44 |
will return a packet that either contains a single nonzero control byte, |
| 45 |
or has a single byte containing zero (\[aq]\[rs]0\[aq]) followed by data |
| 46 |
written on the slave side of the pseudoterminal. |
| 47 |
If the first byte is not |
| 48 |
.B TIOCPKT_DATA |
| 49 |
(0), it is an OR of one |
| 50 |
or more of the following bits: |
| 51 |
.IP |
| 52 |
.ad l |
| 53 |
.TS |
| 54 |
lb l. |
| 55 |
TIOCPKT_FLUSHREAD T{ |
| 56 |
The read queue for the terminal is flushed. |
| 57 |
T} |
| 58 |
TIOCPKT_FLUSHWRITE T{ |
| 59 |
The write queue for the terminal is flushed. |
| 60 |
T} |
| 61 |
TIOCPKT_STOP T{ |
| 62 |
Output to the terminal is stopped. |
| 63 |
T} |
| 64 |
TIOCPKT_START T{ |
| 65 |
Output to the terminal is restarted. |
| 66 |
T} |
| 67 |
TIOCPKT_DOSTOP T{ |
| 68 |
The start and stop characters are |
| 69 |
.BR \[ha]S / \[ha]Q . |
| 70 |
T} |
| 71 |
TIOCPKT_NOSTOP T{ |
| 72 |
The start and stop characters are not |
| 73 |
.BR \[ha]S / \[ha]Q . |
| 74 |
T} |
| 75 |
.TE |
| 76 |
.ad |
| 77 |
.IP |
| 78 |
While packet mode is in use, the presence |
| 79 |
of control status information to be read |
| 80 |
from the master side may be detected by a |
| 81 |
.BR select (2) |
| 82 |
for exceptional conditions or a |
| 83 |
.BR poll (2) |
| 84 |
for the |
| 85 |
.B POLLPRI |
| 86 |
event. |
| 87 |
.IP |
| 88 |
This mode is used by |
| 89 |
.BR rlogin (1) |
| 90 |
and |
| 91 |
.BR rlogind (8) |
| 92 |
to implement a remote-echoed, |
| 93 |
locally |
| 94 |
.BR \[ha]S / \[ha]Q |
| 95 |
flow-controlled remote login. |
| 96 |
.TP |
| 97 |
.B TIOCGPKT |
| 98 |
Return the current packet mode setting in the integer pointed to by |
| 99 |
.IR mode . |
| 100 |
.TP |
| 101 |
.B TIOCSPTLCK |
| 102 |
Set (if |
| 103 |
.I *lock |
| 104 |
is nonzero) or remove (if |
| 105 |
.I *lock |
| 106 |
is zero) the lock on the pseudoterminal slave device. |
| 107 |
(See also |
| 108 |
.BR unlockpt (3).) |
| 109 |
.TP |
| 110 |
.B TIOCGPTLCK |
| 111 |
Place the current lock state of the pseudoterminal slave device |
| 112 |
in the location pointed to by |
| 113 |
.IR lock . |
| 114 |
.TP |
| 115 |
.B TIOCGPTPEER |
| 116 |
Given a file descriptor in |
| 117 |
.I fd |
| 118 |
that refers to a pseudoterminal master, |
| 119 |
open (with the given |
| 120 |
.BR open (2)-style |
| 121 |
.IR flags ) |
| 122 |
and return a new file descriptor that refers to the peer |
| 123 |
pseudoterminal slave device. |
| 124 |
This operation can be performed |
| 125 |
regardless of whether the pathname of the slave device |
| 126 |
is accessible through the calling process's mount namespace. |
| 127 |
.IP |
| 128 |
Security-conscious programs interacting with namespaces may wish to use this |
| 129 |
operation rather than |
| 130 |
.BR open (2) |
| 131 |
with the pathname returned by |
| 132 |
.BR ptsname (3), |
| 133 |
and similar library functions that have insecure APIs. |
| 134 |
(For example, confusion can occur in some cases using |
| 135 |
.BR ptsname (3) |
| 136 |
with a pathname where a devpts filesystem |
| 137 |
has been mounted in a different mount namespace.) |
| 138 |
.SH RETURN VALUE |
| 139 |
On success, |
| 140 |
0 is returned. |
| 141 |
On error, |
| 142 |
\-1 is returned, and |
| 143 |
.I errno |
| 144 |
is set to indicate the error. |
| 145 |
.SH ERRORS |
| 146 |
.TP |
| 147 |
.B ENOTTY |
| 148 |
.SH HISTORY |
| 149 |
.TP |
| 150 |
.B TIOCGPKT |
| 151 |
Linux 3.8. |
| 152 |
.TP |
| 153 |
.B TIOCGPTLCK |
| 154 |
Linux 3.8. |
| 155 |
.TP |
| 156 |
.B TIOCGPTPEER |
| 157 |
.\" linux.git commit 54ebbfb1603415d9953c150535850d30609ef077 |
| 158 |
Linux 4.13. |
| 159 |
.P |
| 160 |
The BSD ioctls |
| 161 |
.BR TIOCSTOP , |
| 162 |
.BR TIOCSTART , |
| 163 |
.BR TIOCUCNTL , |
| 164 |
and |
| 165 |
.B TIOCREMOTE |
| 166 |
have not been implemented under Linux. |
| 167 |
.SH SEE ALSO |
| 168 |
.BR ioctl (2), |
| 169 |
.BR ioctl_tty (2) |