From 12081203afe80b52127190d9bfa26ed2caa42a30 Mon Sep 17 00:00:00 2001 From: Bob Burger Date: Wed, 12 Feb 2020 19:45:24 -0500 Subject: [PATCH] handle CTRL-C in ta6nt without expression editor original commit: 7ca7ad78a278278df55140617a3112f5271f42d8 --- c/new-io.c | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/c/new-io.c b/c/new-io.c index 8a8aee293a..d1ab66bb1c 100644 --- a/c/new-io.c +++ b/c/new-io.c @@ -460,11 +460,22 @@ ptr S_bytevector_read(ptr file, ptr bv, iptr start, iptr count, IBOOL gzflag) { SetLastError(0); m = read_console(&BVIT(bv,start), (IO_SIZE_T)count); error_code = GetLastError(); - SetConsoleCtrlHandler(NULL, FALSE); if (m == 0 && error_code == 0x3e3) { + /* Guard against Windows calling the ConsoleCtrlHandler after we + * turn it back on by waiting a bit. */ + Sleep(1); +#ifdef PTHREADS + /* threaded io.ss doesn't handle interrupts because + * with-tc-mutex disables them, so bail out. */ + SetConsoleCtrlHandler(NULL, FALSE); + REACTIVATEandUNLOCK(tc, bv) + S_noncontinuable_interrupt(); +#else KEYBOARDINTERRUPTPENDING(tc) = Strue; SOMETHINGPENDING(tc) = Strue; +#endif } + SetConsoleCtrlHandler(NULL, FALSE); } else #endif /* WIN32 */ {