RogueCSDev RogueCSDev - 11 months ago 67
Linux Question

How to detect XOFF and XON in Linux terminal application

Certain control sequences have special effects in Linux, such as

which sends
. I can handle signals easily enough, but it appears
(XOFF) and
(XON) are special snowflakes. I know their effect (to pause input) can be disabled in the console with
stty -ixon
, and I could use some trickery to run that command, but that feels like a cheap workaround.

Is there a proper way to rid these sequences of their special effect and get their actual ASCII values (
) using system calls? I know it is doable because the text editor Nano does it, but for the life of me I can't find where it's being handled. I already tried searching the repo for "XOFF".

Answer Source

Use the tcgetattr() and tcsetattr() system calls to turn off the IXON flag on standard input, as explained in this manual page.