Properly handle soft-kill (Ctrl-C)
Brought to you by:
bpeng2000
Currently, if user press Ctr-C, vtools will exit immediately, leaving possibly a damaged project. We should
1. at least make sure the project is properly closed before exit
2. allow a command to quite properly (e.g. after completion of a task, or reverting to a status before command is executed)
3. set a break point where the next command can pick up from the middle.
The method to handle soft-kill signal is listed below.
import signal
import sys
def signal_handler(signal, frame):
print 'You pressed Ctrl+C!'
sys.exit(0)
signal.signal(signal.SIGINT, signal_handler)
print 'Press Ctrl+C'
signal.pause()