0

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).

2 Answers 2

1

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.

1

different control character […] control characters

I note the plural. You are looking for non-canonical input mode, known before the POSIX standard as raw mode. This is the mode that applications that use GNU Readline, or ZLE, or libedit employ. Their code sets it with the tcgetattr(), cfmakeraw() and tcsetattr() library functions, or similar. These are also the underpinnings of stty raw. (Note the existence of stty sane if you play with this.)

Further reading

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .