Menu

#5 Properly handle soft-kill (Ctrl-C)

open
nobody
command (4)
5
2012-12-10
2011-12-09
Anonymous
No

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()

Discussion

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.