Reputation: 4996
I'm catching ctrl-c with a signal handler and was wondering if there is a nicer way to hide the ^C that is printed to terminal than go os.system("\b") or similar. I only 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)
My current solution is above
Upvotes: 7
Views: 1212