From: "Nobuyoshi.Nakada" Date: 2000-10-31T15:41:16+09:00 Subject: [ruby-dev:11345] Re: SIGINT on windows なかだです。 At Tue, 31 Oct 2000 00:47:14 +0900 Daisuke Aoki wrote: > シグナルを処理しているスレッドは Windows 95 では単一です。だから、 > 競合は起こりません。メインスレッドとシグナルスレッド間のみの競合のみを > 考えればいいのです。で、シグナルスレッドはプロセスに単一で、シグナルスレッドを > 殺すと、プロセスはシグナルの処理をできなくなります。 これで思い付いたことがあります。EnterCriticalSection() も 青木さんの代 替コードも、同一スレッドの再入は防げません。ひょっとしてこれがまずいので は。 --- win32/win32.c-1030- Mon Oct 30 12:54:04 2000 +++ win32/win32.c Tue Oct 31 15:29:54 2000 @@ -2766,6 +2810,7 @@ int win32_main_context(int arg, void (*handler)(int)) { static HANDLE interrupt_done = NULL; + static LONG interrupting = 0; struct handler_arg_t harg; CONTEXT ctx_orig; HANDLE current_thread = GetCurrentThread(); @@ -2781,8 +2826,10 @@ # endif /* USE_INTERRUPT_WINSOCK */ #endif - if (!IsWinNT()) { - Sleep(200); /* for safety on Windows 9x */ + /* signal thread is only one on Windows 9x */ + if (!IsWinNT() && InterlockedExchange(&interrupting, 1)) { + /* can't handle new signal */ + return TRUE; } RUBY_CRITICAL({ /* the main thread must be in user state */ @@ -2831,6 +2878,8 @@ SetThreadPriority(current_thread, old_priority); + interrupting = FALSE; + return TRUE; } -- --- 僕の前にBugはない。 --- 僕の後ろにBugはできる。 中田 伸悦