changeset 138:517dd43f06f8

Upreckon now properly reports exiting due to SIGINT to the calling process
author Oleg Oshmyan <chortos@inbox.lv>
date Tue, 24 May 2011 21:33:32 +0100
parents f4361d557929
children 2d465a8a679c
files upreckon-vcs
diffstat 1 files changed, 10 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/upreckon-vcs	Tue May 24 20:55:16 2011 +0100
+++ b/upreckon-vcs	Tue May 24 21:33:32 2011 +0100
@@ -130,7 +130,16 @@
 		say()
 		say('Grand total: %g/%g weighted points; %d/%d problems solved fully' % (realscore, maxscore, nfulltasks, ntasks))
 except KeyboardInterrupt:
-	sys.exit('Exiting due to a keyboard interrupt.')
+	say('Exiting due to a keyboard interrupt.', end='', file=sys.stderr)
+	try:
+		import os, signal
+		signal.signal(signal.SIGINT, signal.SIG_DFL)
+		os.kill(os.getpid(), signal.SIGINT)
+	except Exception:
+		pass
+	# Do this even if we got no exceptions, just in case
+	say(file=sys.stderr)
+	sys.exit(1)
 
 if options.pause:
 	say('Press any key to exit...')