[#11131] Re: SIGINT on windows — Daisuke Aoki <dai@...>

青木です。

36 messages 2000/10/04
[#11217] Re: SIGINT on windows — Daisuke Aoki <dai@...> 2000/10/14

青木です。

[#11250] Re: SIGINT on windows — Daisuke Aoki <dai@...> 2000/10/16

青木です。

[#11258] Re: SIGINT on windows — "Nobuyoshi.Nakada" <nobu.nakada@...> 2000/10/17

なかだです。

[#11298] Re: SIGINT on windows — "Nobuyoshi.Nakada" <nobu.nakada@...> 2000/10/27

なかだです。

[#11183] EPOC32 and Ruby 1.7 — WATANABE Hirofumi <eban@...>

わたなべです.

44 messages 2000/10/12
[#11188] Re: EPOC32 and Ruby 1.7 — matz@... (Yukihiro Matsumoto) 2000/10/12

まつもと ゆきひろです

[#11191] ruby-bugs-ja PR#20 — Kazuhiro NISHIYAMA <zn@...> 2000/10/12

On Fri, 13 Oct 2000 00:17:14 +0900

[#11205] Re: ruby-bugs-ja PR#20 — Kazuhiro NISHIYAMA <zn@...> 2000/10/13

同じ問題を短いスクリプトで再現できました。

[#11210] Re: Thread.new with irb (PR#20) — matz@... (Yukihiro Matsumoto) 2000/10/13

まつもと ゆきひろです

[#11211] Re: Thread.new with irb (PR#20) — Kazuhiro NISHIYAMA <zn@...> 2000/10/13

On Sat, 14 Oct 2000 03:41:18 +0900

[#11221] Re: Thread.new with irb (PR#20) — Kazuhiro NISHIYAMA <zn@...> 2000/10/14

[ruby-dev:11205]と同じスクリプトで-dをつけていると

[#11306] Ruby I18N — matz@... (Yukihiro Matsumoto)

まつもと ゆきひろです

130 messages 2000/10/28
[#11307] Re: Ruby I18N — " たけ (tk)" <ggb03124@...> 2000/10/28

たけ(tk)です。

[#11310] Re: Ruby I18N — kenn@... 2000/10/29

長沢です。

[#11314] Re: Ruby I18N — matz@... (Yukihiro Matsumoto) 2000/10/29

まつもと ゆきひろです

[#11315] Re: Ruby I18N — Shugo Maeda <shugo@...> 2000/10/30

前田です。

[#11324] Re: Ruby I18N — TAKAHASHI Masayoshi <maki@...> 2000/10/30

高橋征義です。

[#11337] Re: Ruby I18N — Yasushi Shoji <yashi@...> 2000/10/30

At Mon, 30 Oct 2000 13:15:23 +0900,

[#11346] Re: Ruby I18N — TAKAHASHI Masayoshi <maki@...> 2000/10/31

某2ちゃんねるで自分の名前を見つけてびびった高橋征義です。

[#11347] Re: Ruby I18N — matz@... (Yukihiro Matsumoto) 2000/10/31

まつもと ゆきひろです

[#11370] Re: Ruby I18N — TAKAHASHI Masayoshi <maki@...> 2000/11/02

高橋征義です。

[#11372] Re: Ruby I18N — matz@... (Yukihiro Matsumoto) 2000/11/02

まつもと ゆきひろです

[#11375] Re: Ruby I18N — TAKAHASHI Masayoshi <maki@...> 2000/11/04

高橋征義です。

[#11378] Re: Ruby I18N — " たけ (tk)" <ggb03124@...> 2000/11/05

たけ(tk)です。

[#11379] Re: Ruby I18N — matz@... (Yukihiro Matsumoto) 2000/11/05

まつもと ゆきひろです

[#11380] Re: Ruby I18N — " たけ (tk)" <ggb03124@...> 2000/11/05

たけ(tk)です。

[#11382] Re: Ruby I18N — matz@... (Yukihiro Matsumoto) 2000/11/05

まつもと ゆきひろです

[#11393] Re: Ruby I18N — "たけ(tk)" <ggb03124@...> 2000/11/07

たけ(tk)です。 ・・ 長文ご注意。

[#11396] Re: Ruby I18N — matz@... (Yukihiro Matsumoto) 2000/11/07

まつもと ゆきひろです

[#11397] Re: Ruby I18N — Yasushi Shoji <yashi@...> 2000/11/07

At Tue, 7 Nov 2000 15:46:29 +0900,

[#11398] Re: Ruby I18N — matz@... (Yukihiro Matsumoto) 2000/11/07

まつもと ゆきひろです

[#11399] Re: Ruby I18N — Tanaka Akira <akr@...17n.org> 2000/11/07

In article <E13t3dt-0002Fp-00@ev.netlab.zetabits.co.jp>,

[#11401] Re: Ruby I18N — matz@... (Yukihiro Matsumoto) 2000/11/07

まつもと ゆきひろです

[#11404] Re: Ruby I18N — "たけ(tk)" <ggb03124@...> 2000/11/07

たけ(tk)です。

[#11406] Re: Ruby I18N — Yasushi Shoji <yashi@...> 2000/11/07

At Tue, 7 Nov 2000 19:06:27 +0900,

[#11407] Re: Ruby I18N — "たけ(tk)" <ggb03124@...> 2000/11/07

たけ(tk)です。

[#11409] Re: Ruby I18N — Minero Aoki <aamine@...> 2000/11/07

あおきです。

[#11423] Re: Ruby I18N — Tanaka Akira <akr@...17n.org> 2000/11/08

In article <E13t4Hq-0002GS-00@ev.netlab.zetabits.co.jp>,

[#11426] Re: Ruby I18N — matz@... (Yukihiro Matsumoto) 2000/11/08

まつもと ゆきひろです

[#11427] Re: Ruby I18N — Tanaka Akira <akr@...17n.org> 2000/11/08

In article <E13tMYW-0002te-00@ev.netlab.zetabits.co.jp>,

[#11428] Re: Ruby I18N — matz@... (Yukihiro Matsumoto) 2000/11/08

まつもと ゆきひろです

[#11430] Re: Ruby I18N — "たけ(tk)" <ggb03124@...> 2000/11/08

たけ(tk)です。

[#11433] Re: Ruby I18N — matz@... (Yukihiro Matsumoto) 2000/11/08

まつもと ゆきひろです

[#11446] 『文字列は文字の配列か』 — " たけ (tk)" <ggb03124@...> 2000/11/08

たけ(tk)です。

[#11470] Proposal of "Array of CharCode" — " たけ (tk)" <ggb03124@...> 2000/11/10

たけ(tk)です。

[#11471] Re: Proposal of "Array of CharCode" — matz@... (Yukihiro Matsumoto) 2000/11/10

まつもと ゆきひろです

[#11450] Re: Ruby I18N — Tanaka Akira <akr@...17n.org> 2000/11/09

In article <E13tNkT-00030l-00@ev.netlab.zetabits.co.jp>,

[ruby-dev:11326] Re: SIGINT on windows

From: "Nobuyoshi.Nakada" <nobu.nakada@...>
Date: 2000-10-30 04:19:54 UTC
List: ruby-dev #11326
なかだです。

At Sun, 29 Oct 2000 23:38:53 +0900
Daisuke Aoki <dai@sweetparty.ne.jp> wrote:
> で、Windows 95 では flock() は大丈夫っぽそうです。って、これは
>  USE_WAITEVENT を 95 にしていない場合です。USE_WAITEVENT と
>  USE_CRITICALSECTION は 95 にすると、Windows 95 だとシグナル処理時に
> タイミング的に止まる可能性があるという問題を確認しました。ふつうに
> 使っていれば止まらないですけど(止まるとは、Ctrl+Alt+del で Ruby を
> 終わらせないとOS 自体が止まった状況になる現象です。)

  考えてみたら、win32_asynchronize() は USE_WAITEVENT が有効の状態じゃな
きゃまったく意味ありませんね。ということで win32_asynchronize() にもシス
テムのチェックを入れました。

> あと、Windows 95 では、シグナル処理が連続で呼ばれるとだめみたいなので
> (例えば、Ctrl-C を押しっぱなしにすると止まる、回避のための対策に
> 成功しなかった)、以下を入れてください。Sleep(200) ですが、
> タイムスライスの msec の設定に依存するのかもしれませんけど、
> もっと大きい方がいいのかな。

  優先度の高い signal thread 同士が win32_disable_interrupt() で実行権を
取り合って、他のプロセスにまで回らないということかな。以前優先度を下げて
もダメだったということですが、win32_disable_interrupt() の Sleep() を長
めにしてもダメでしたか。

  NT でも SuspendThread() の前に優先度を下げちゃうと SuspendThread() で
きなくなるし。いやー難しいな。> Windows

  つーことで[ruby-dev:11302]からの差分です。


--- win32/win32.c-	Fri Oct 27 14:41:42 2000
+++ win32/win32.c	Mon Oct 30 12:54:04 2000
@@ -43,4 +43,8 @@
 #endif  /* USE_CRITICALSECTION */
 
+#if !USE_WAITEVENT
+#undef USE_INTERRUPT_WINSOCK
+#endif /* !USE_WAITEVENT */
+
 #ifdef WIN32_DEBUG
 #define Debug(something) something
@@ -98,5 +102,7 @@
 
 /* interrupt stuff */
+#if USE_WAITEVENT
 static HANDLE interrupted_event;
+#endif /* USE_WAITEVENT */
 
 HANDLE GetCurrentThreadHandle(void)
@@ -1974,5 +1980,6 @@
 	return file_nfds;
     }
-#ifdef USE_INTERRUPT_WINSOCK
+
+#if USE_INTERRUPT_WINSOCK
     if (ex)
 	trap = *ex;
@@ -1984,4 +1991,5 @@
     ex = &trap;
 #endif /* USE_INTERRUPT_WINSOCK */
+
     if ((r = select (nfds, rd, wr, ex, timeout)) == SOCKET_ERROR) {
 	errno = WSAGetLastError();
@@ -2027,11 +2035,16 @@
     main_thread.handle = GetCurrentThreadHandle();
     main_thread.id = GetCurrentThreadId();
-#ifdef USE_INTERRUPT_WINSOCK
-    interrupted_event = (HANDLE)WSACreateEvent();
-#else  /* USE_INTERRUPT_WINSOCK */
-    interrupted_event = CreateEvent(NULL, FALSE, FALSE, NULL);
-#endif /* USE_INTERRUPT_WINSOCK */
-    if (!interrupted_event)
-	rb_fatal("Unable to create interrupt event!\n");
+#if USE_WAITEVENT
+    if (USE_WAITEVENT == 95 || IsWinNT()) {
+# if USE_INTERRUPT_WINSOCK
+	interrupted_event = (HANDLE)WSACreateEvent();
+# else  /* USE_INTERRUPT_WINSOCK */
+	interrupted_event = CreateEvent(NULL, FALSE, FALSE, NULL);
+# endif /* USE_INTERRUPT_WINSOCK */
+
+	if (!interrupted_event)
+	    rb_fatal("Unable to create interrupt event!\n");
+    }
+#endif /* USE_WAITEVENT */
 }
 
@@ -2618,11 +2631,12 @@
 	events[count++] = interrupted_event;
 
-# ifdef USE_INTERRUPT_WINSOCK
+# if USE_INTERRUPT_WINSOCK
 	ret = WSAWaitForMultipleEvents(count, events, FALSE, timeout, TRUE);
 # else  /* USE_INTERRUPT_WINSOCK */
 	ret = WaitForMultipleObjects(count, events, FALSE, timeout);
 # endif /* USE_INTERRUPT_WINSOCK */
+
 	if (ret == WAIT_OBJECT_0 + count - 1) {
-# ifdef USE_INTERRUPT_WINSOCK
+# if USE_INTERRUPT_WINSOCK
 	    WSAResetEvent(interrupted_event);
 # endif /* USE_INTERRUPT_WINSOCK */
@@ -2639,5 +2653,5 @@
     } else {
 	Sleep(timeout);
-	return FALSE;
+	return WAIT_TIMEOUT;
     }
 #endif /* USE_WAITEVENT != 95 */
@@ -2755,12 +2769,20 @@
     struct handler_arg_t harg;
     CONTEXT ctx_orig;
+    HANDLE current_thread = GetCurrentThread();
+    int old_priority = GetThreadPriority(current_thread);
 
-#ifdef USE_INTERRUPT_WINSOCK
+    if (GetCurrentThreadId() == main_thread.id) return FALSE;
+
+#if USE_WAITEVENT
+# if USE_INTERRUPT_WINSOCK
     WSASetEvent(interrupted_event);
-#else  /* USE_INTERRUPT_WINSOCK */
+# else  /* USE_INTERRUPT_WINSOCK */
     SetEvent(interrupted_event);
-#endif /* USE_INTERRUPT_WINSOCK */
+# endif /* USE_INTERRUPT_WINSOCK */
+#endif
 
-    if (GetCurrentThreadId() == main_thread.id) return FALSE;
+    if (!IsWinNT()) {
+	Sleep(200);		/* for safety on Windows 9x */
+    }
 
     RUBY_CRITICAL({		/* the main thread must be in user state */
@@ -2768,4 +2790,5 @@
 
 	SuspendThread(main_thread.handle);
+	SetThreadPriority(current_thread, GetThreadPriority(main_thread.handle));
 
 	ZeroMemory(&ctx, sizeof(CONTEXT));
@@ -2789,30 +2812,23 @@
     });
 
-    {
-	HANDLE current_thread = GetCurrentThread();
-	int old_priority = GetThreadPriority(current_thread);
-
-	/* give a chance to the main thread */
-	SetThreadPriority(current_thread, GetThreadPriority(main_thread.handle));
-	yield_once();
-	WaitForSingleObject(interrupt_done, INFINITE); /* handshaking */
+    /* give a chance to the main thread */
+    yield_once();
+    WaitForSingleObject(interrupt_done, INFINITE); /* handshaking */
 
+    if (!harg.status) {
+	/* no exceptions raised, restore old context. */
 	RUBY_CRITICAL(
-	    if (!harg.status) {
-		/* no exceptions raised, restore old context. */
+	    /* ensure the main thread is in user state. */
+	    yield_until(harg.userstate);
 
-		/* ensure the main thread is in user state. */
-		yield_until(harg.userstate);
-
-		SuspendThread(main_thread.handle);
-		ctx_orig.ContextFlags = CONTEXT_FULL | CONTEXT_FLOATING_POINT;
-		SetThreadContext(main_thread.handle, &ctx_orig);
-		ResumeThread(main_thread.handle);
-	    }
-	    /* otherwise leave the main thread raised */
+	    SuspendThread(main_thread.handle);
+	    ctx_orig.ContextFlags = CONTEXT_FULL | CONTEXT_FLOATING_POINT;
+	    SetThreadContext(main_thread.handle, &ctx_orig);
+	    ResumeThread(main_thread.handle);
 	);
-
-	SetThreadPriority(current_thread, old_priority);
     }
+    /* otherwise leave the main thread raised */
+
+    SetThreadPriority(current_thread, old_priority);
 
     return TRUE;
@@ -2824,11 +2840,14 @@
 }
 
-#define catch_interrupt win32_sleep
-
-void win32_enter_syscall(void)
+static void catch_interrupt(void)
 {
     yield_once();
-    catch_interrupt(0);
+    win32_sleep(0);
     CHECK_INTS;
+}
+
+void win32_enter_syscall(void)
+{
+    catch_interrupt();
     win32_disable_interrupt();
 }
@@ -2837,9 +2856,8 @@
 {
     win32_enable_interrupt();
-    yield_once();
-    catch_interrupt(0);
-    CHECK_INTS;
+    catch_interrupt();
 }
 
+#if USE_WAITEVENT
 struct asynchronous_arg_t {
     /* output field */
@@ -2860,67 +2878,76 @@
     return (DWORD)arg->func(arg->self, arg->argc, arg->argv);
 }
+#endif /* USE_WAITEVENT */
 
 VALUE win32_asynchronize(asynchronous_func_t func,
 			 VALUE self, int argc, VALUE* argv, VALUE intrval)
 {
-    DWORD val;
-    BOOL interrupted = FALSE;
-    HANDLE thr;
+#if USE_WAITEVENT
+    if (USE_WAITEVENT == 95 || IsWinNT()) {
+	DWORD val;
+	BOOL interrupted = FALSE;
+	HANDLE thr;
 
-    RUBY_CRITICAL({
-	struct asynchronous_arg_t arg;
+	RUBY_CRITICAL({
+	    struct asynchronous_arg_t arg;
 
-	arg.stackaddr = NULL;
-	arg.func = func;
-	arg.self = self;
-	arg.argc = argc;
-	arg.argv = argv;
+	    arg.stackaddr = NULL;
+	    arg.func = func;
+	    arg.self = self;
+	    arg.argc = argc;
+	    arg.argv = argv;
 
-	thr = CreateThread(NULL, 0, call_asynchronous, &arg, 0, &val);
+	    thr = CreateThread(NULL, 0, call_asynchronous, &arg, 0, &val);
 
-	if (thr) {
-	    yield_until(arg.stackaddr);
+	    if (thr) {
+		yield_until(arg.stackaddr);
 
-	    if (wait_events(thr, INFINITE) != WAIT_OBJECT_0) {
-		interrupted = TRUE;
+		if (wait_events(thr, INFINITE) != WAIT_OBJECT_0) {
+		    interrupted = TRUE;
 
-		if (TerminateThread(thr, intrval)) {
-		    yield_once();
-		}
+		    if (TerminateThread(thr, intrval)) {
+			yield_once();
+		    }
 
-		val = intrval;
-	    }
-	    else {
-		GetExitCodeThread(thr, &val);
-	    }
+		    val = intrval;
+		}
+		else {
+		    GetExitCodeThread(thr, &val);
+		}
 
-	    CloseHandle(thr);
+		CloseHandle(thr);
 
-	    if (interrupted) {
-		/* must release stack of killed thread, why Windows doesn't do this? */
-		MEMORY_BASIC_INFORMATION m;
-
-		memset(&m, 0, sizeof(m));
-		if (!VirtualQuery(arg.stackaddr, &m, sizeof(m))) {
-		    Debug(fprintf(stderr, "couldn't get stack base:%p:%d\n",
-				  arg.stackaddr, GetLastError()));
-		}
-		else if (!VirtualFree(m.AllocationBase, 0, MEM_RELEASE)) {
-		    Debug(fprintf(stderr, "couldn't release stack:%p:%d\n",
-				  m.AllocationBase, GetLastError()));
+		if (interrupted) {
+		    /* must release stack of killed thread, why doesn't Windows? */
+		    MEMORY_BASIC_INFORMATION m;
+
+		    memset(&m, 0, sizeof(m));
+		    if (!VirtualQuery(arg.stackaddr, &m, sizeof(m))) {
+			Debug(fprintf(stderr, "couldn't get stack base:%p:%d\n",
+				      arg.stackaddr, GetLastError()));
+		    }
+		    else if (!VirtualFree(m.AllocationBase, 0, MEM_RELEASE)) {
+			Debug(fprintf(stderr, "couldn't release stack:%p:%d\n",
+				      m.AllocationBase, GetLastError()));
+		    }
 		}
 	    }
+	});
+
+	if (!thr) {
+	    rb_fatal("failed to launch waiter thread:%d", GetLastError());
 	}
-    });
 
-    if (!thr) {
-	rb_fatal("failed to launch waiter thread:%d", GetLastError());
-    }
+	if (interrupted) {
+	    errno = EINTR;
+	    CHECK_INTS;
+	}
 
-    if (interrupted) {
-	errno = EINTR;
-	CHECK_INTS;
+	return val;
     }
+#endif /* USE_WAITEVENT */
 
-    return val;
+#if USE_WAITEVENT != 95
+    return func(self, argc, argv);
+#endif /* USE_WAITEVENT != 95 */
 }


-- 
--- 僕の前にBugはない。
--- 僕の後ろにBugはできる。
    中田 伸悦


In This Thread