How to disable control character shell interception?

I am writing a curses application in Python under UNIX. I want the user to be able to use CY to pull a la Emacs from the kill ring.

Undoubtedly, the problem is that CY is caught by my shell, which then sends SIGTSTP to my process. In addition, CZ also causes SIGTSTP to be sent, so signal capture means that CY and CZ are indistinguishable (although even without this the only solutions that I can think of are extremely hacky).

I know what I'm asking, maybe (in C, if not in Python), since Emacs does this. How can I turn off special shell processing by some control characters sent from the keyboard and display the corresponding characters in the stdin process?

+3
source share
2 answers

See module termiosand man page termios(3).

+2
source

For basic functionality use tty. For example, a call tty.setraw(sys.stdin)puts the standard input terminal in raw mode.

For a more general case, Python comes with a termios library , but you probably need some experience with termios to know how to use it.

Alternatively, a cheap way is to lay out on stty, which is the command line interface for termios.

+1
source

Source: https://habr.com/ru/post/1728255/


All Articles