Linux – Prevent the line discipline from handling control characters

control-characterslinuxterminal

When you send a control character from the terminal, for example if you pressed Ctrl+C, the line discipline will receive the byte representing this control character (which is 0x03 in the case of Ctrl+C).

Now instead of the line discipline sending the byte 0x03 to the program associated with the terminal, it will instead send it the SIGINT signal (or it will do some other action if it is a different control character).

Now is there a way to prevent the line discipline from handling control characters, so what I want is for the program associated with the terminal to receive the actual bytes representing the control characters (0x03 in our case).

Best Answer

On linux, you'd use

$ stty intr undef

on the terminal concerned. That sets the interrupt character to nothing ("undef"). To restore you would use

$ stty intr ^c

See man stty for details.

Related Question