From 6d7f4089e1e8b2207df85ffd76b1cee9400292a7 Mon Sep 17 00:00:00 2001 From: yjqww6 Date: Sat, 11 Jun 2016 00:49:25 +0800 Subject: [PATCH] fix thread blocked by expeditor original commit: fa7516efa7bee58b2a7307e504ed97fc3bc69731 --- c/expeditor.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/c/expeditor.c b/c/expeditor.c index d04c79a977..556847d52b 100644 --- a/c/expeditor.c +++ b/c/expeditor.c @@ -95,8 +95,19 @@ static ptr s_ee_read_char(IBOOL blockp) { S_LastErrorString()); if (NumberOfEvents == 0) return Sfalse; } - - if (!ReadConsoleInput(hStdin, irInBuf, 1, &cNumRead)) + +#ifdef PTHREADS + ptr tc = get_thread_context(); + deactivate_thread(tc); +#endif + + BOOL succ = ReadConsoleInput(hStdin, irInBuf, 1, &cNumRead); + +#ifdef PTHREADS + reactivate_thread(tc); +#endif + + if (!succ) S_error1("expeditor", "error getting console info: ~a", S_LastErrorString());