Python hide ^ C from sigint

I catch ctrl-c with a signal handler and wonder if there is a better way to hide ^ C, which is printed to the terminal, than go os.system ("\ b") or similar. I really really care about Unix.

    def read(self, time_s):

        setup = ['Sensor', 'sensors', '\x00']

        # Closure for signal handler to allow access to self
        def sigintHandler(*args):
            self.close()
            sys.stdout.write('\b\b\r')  # Current solution
            sys.stdout.flush()
            sys.exit(0)

        signal.signal(signal.SIGINT,sigintHandler)

Edit

My current solution is higher

+4
source share

All Articles