Catching KeyboardInterrupt on stdin (Ctrl-C)

Questions and discussion about The WiPy 1.0 board and CC3200 boards.
Target audience: Users with a WiPy 1.0 or CC3200 board.
Post Reply
User avatar
Roberthh
Posts: 3667
Joined: Sat May 09, 2015 4:13 pm
Location: Rhineland, Europe

Catching KeyboardInterrupt on stdin (Ctrl-C)

Post by Roberthh » Fri Oct 23, 2015 7:25 pm

Hello all,
I'm trying to catch the keyboard interrupt caused Ctr-C on stdin of WiPy, and for instance ignore it. I have a few lines of code that seem to work:

Code: Select all

        try:
            ch = sys.stdin.read(1)
        except KeyboardInterrupt:
            pass
It works as far as the program including it is not interrupted. BUT, the next character entered is lost. Do you have any hint, how that could be avoided?
Alternatively: Which socket(stream is stdin connected to?
Regards

Post Reply