To be specific, let's speak in pseudo-terminal terms. Suppose we have file descriptors master
and slave
for a pseudo-terminal pair (suppose it is a controlling tty). Disabling IXON
on master
(or slave
, which works the same) means that when we do write(master, &control_s_code, 1)
, read(slave, &byte, 1)
will get this code. The same concerns control_q_code
. The question is: what does disabling IXOFF
do?

- 713
1 Answers
IXOFF
is not implemented on pseudo-ttys, and setting IXOFF
on a pseudo-tty has no effect whatsoever.
IXOFF
should cause the tty driver to send a VSTOP
character to the other side when its input queue is full (which should prevent it from sending in more data), and a VSTART
character when it has processed it and there's place for more data.
This is different from IXON
, which will cause the tty driver to respect the VSTART
/VSTOP
characters sent from the other side, and upon receiving a VSTOP
(^S
) character, stop any transmission until a VSTART
(^Q
) character is received.
In the case of a pseudo-tty, the "other side" is the master pty, eg. your terminal emulator; when you press ^S
, it's the IXON
, not the IXOFF
setting which will cause the slave tty to stop echoing back the entered characters and displaying the data written to it (which will be queued until the output queue is full, when any write(2)
to the slave tty will either block or return EAGAIN
).
Implementing flow control on pseudo-ttys is not needed, because the kernel always knows (by checking a struct field or similar) whether the input queue of the slave has filled up, and can just block the process writing to the master pty.
The software flow control is only useful when using a real serial connection without out-of-band signals like RTS/CTS: unlike any Unix, TCP or other "pipe" abstraction, a wire is not buffering and will not fill up and block until the receiver has read all the state changes off it.
IXOFF
do for an ordinary (i.e., not pseudo) tty? – Igor Liferenko Oct 07 '19 at 03:21gnome-terminal
(andxterm
) developers: pressing^S
in bash can be used to verify this. – Igor Liferenko Oct 07 '19 at 03:23^S
/^Q
is controlled by theIXON
, not theIXOFF
settings; I've expanded on that in the answer. The terminal emulator doesn't have to care about that at all -- it simply writes the^S
and^Q
characters into the master fd -- it's up to the tty driver to handle or not handle them. – Oct 07 '19 at 04:52IXOFF
is the same asIXON
, but for the opposite side of the tty. Right? – Igor Liferenko Oct 07 '19 at 05:09IXON
orIXOFF
does not affect in any way what the remote side will do. What may be confusing is that any line discipline ioctls (eg.TIOCSETS*
which implementtcsetattr
) on the master pty are always acting on the slave pty. The master pty is not a real pty, and does not do any line discipline like flow control or anything, it simply reads and writes raw data to the slave. See this for some details about how it works in Linux. – Oct 07 '19 at 05:21tcsetattr
on the master will only affect the slave. The master fd is simply set to raw mode / pass-through and is not user-serviceable. – Oct 07 '19 at 05:30vte2.91
to disableIXON
using master fd right after pty is created (to get rid of annoying effects of pressing ^S in bash and other programs). Is this bad in any way? – Igor Liferenko Oct 07 '19 at 05:39expect
, the answer is certainly NO. If it's a terminal emulator, a user may expect to stop scrolling with^S
, and will hate you if she has to look in the manual how to enable it back ;-) – Oct 07 '19 at 05:40stty -ixon
in~/.bashrc
would've worked, too. – Oct 07 '19 at 05:41less
,bash
) must be patched/configured to disable IXON, which is worse than patching just one terminal emulator. And finally I see the use case for ^S/^Q in bash - scrolling! Never occurred to me before. But I deal with this problem in another way - I use unlimited scroll buffer. – Igor Liferenko Oct 07 '19 at 05:43stty -ixon
works --less
,vi
or the readline library (as used bybash
) will not reenable it back. – Oct 07 '19 at 05:51