changeset 210:8c4e92fb32d8

Keyboard interrupts now satisfy the Press any key to exit... prompt
author Oleg Oshmyan <chortos@inbox.lv>
date Thu, 18 Aug 2011 02:51:31 +0300
parents c03a8113685d
children 78be952f6b40
files upreckon/_unixmodule.cpp upreckon/upreckon-vcs
diffstat 2 files changed, 21 insertions(+), 12 deletions(-) [+]
line wrap: on
line diff
--- a/upreckon/_unixmodule.cpp	Thu Aug 18 02:41:46 2011 +0300
+++ b/upreckon/_unixmodule.cpp	Thu Aug 18 02:51:31 2011 +0300
@@ -1276,7 +1276,13 @@
 	if (catch_escape)
 	{
 		char c;
-		while (read(0, &c, 1) == -1 && errno == EINTR);
+		while (read(0, &c, 1) == -1 && errno == EINTR)
+		{
+			if (PyErr_CheckSignals() == -1)
+			{
+				return NULL;
+			}
+		}
 	}
 #endif
 	Py_RETURN_NONE;
--- a/upreckon/upreckon-vcs	Thu Aug 18 02:41:46 2011 +0300
+++ b/upreckon/upreckon-vcs	Thu Aug 18 02:51:31 2011 +0300
@@ -109,14 +109,17 @@
 	say(file=sys.stderr)
 	sys.exit(1)
 
-if options.pause:
-	say('Press any key to exit...')
-	sys.stdout.flush()
-	
-	if pause:
-		pause()
-	elif callable(globalconf.pause):
-		globalconf.pause()
-	else:
-		with open(os.devnull, 'w') as devnull:
-			subprocess.call(globalconf.pause, shell=True, stdout=devnull, stderr=subprocess.STDOUT)
\ No newline at end of file
+try:
+	if options.pause:
+		say('Press any key to exit...')
+		sys.stdout.flush()
+		
+		if pause:
+			pause()
+		elif callable(globalconf.pause):
+			globalconf.pause()
+		else:
+			with open(os.devnull, 'w') as devnull:
+				subprocess.call(globalconf.pause, shell=True, stdout=devnull, stderr=subprocess.STDOUT)
+except KeyboardInterrupt:
+	pass