chicken-hackers
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Chicken-hackers] [PATCH] handle SIGINT correctly in csi on windows


From: Felix
Subject: [Chicken-hackers] [PATCH] handle SIGINT correctly in csi on windows
Date: Wed, 14 Dec 2011 03:52:18 -0500 (EST)

The attached patch uses Win32-specific code do detect an interrupt
while reading from a file or console stream. Previously pressing
Ctrl-C in csi would terminate, as the input routines for reading and
peeking characters would return EOF.

This patch fixes ticket #743.
>From 465893b8d139e8736ddfaf02b297e48b2fbdaa2f Mon Sep 17 00:00:00 2001
From: felix <address@hidden>
Date: Wed, 14 Dec 2011 09:46:04 +0100
Subject: [PATCH] Added win32-specific keyboard-interrupt handling in
 read/peek char routines in C runtime system, according to
 information found here:

  http://mail.python.org/pipermail/python-bugs-list/2002-July/012579.html

Without this patch SIGINT will result in the input routine returning EOF
which makes csi exit.
---
 runtime.c |    9 +++++++++
 1 files changed, 9 insertions(+), 0 deletions(-)

diff --git a/runtime.c b/runtime.c
index b7d7d95..dc32a3d 100644
--- a/runtime.c
+++ b/runtime.c
@@ -3956,6 +3956,11 @@ C_regparm C_word C_fcall C_read_char(C_word port)
 
   if(c == EOF) {
     if(errno == EINTR) return C_fix(-1);
+    /* Found here:
+       http://mail.python.org/pipermail/python-bugs-list/2002-July/012579.html 
*/
+#ifdef _WIN32
+    else if(GetLastError() == ERROR_OPERATION_ABORTED) return C_fix(-1);
+#endif
     else return C_SCHEME_END_OF_FILE;
   }
 
@@ -3970,6 +3975,10 @@ C_regparm C_word C_fcall C_peek_char(C_word port)
 
   if(c == EOF) {
     if(errno == EINTR) return C_fix(-1);
+    /* see above */
+#ifdef _WIN32
+    else if(GetLastError() == ERROR_OPERATION_ABORTED) return C_fix(-1);
+#endif
     else return C_SCHEME_END_OF_FILE;
   }
 
-- 
1.7.6.msysgit.0


reply via email to

[Prev in Thread] Current Thread [Next in Thread]