summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ChangeLog14
-rw-r--r--test/ruby/test_thread.rb11
-rw-r--r--win32/win32.c10
3 files changed, 30 insertions, 5 deletions
diff --git a/ChangeLog b/ChangeLog
index 44cc22be5a..39b6b97d01 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,17 @@
+Sat Jan 28 08:18:11 2012 Hiroshi Shirosaki <h.shirosaki@gmail.com>
+
+ * test/ruby/test_thread.rb
+ (TestThreadGroup#test_thread_timer_and_interrupt): skip exit status
+ assertion because we cannot get signal status on Windows.
+
+ * win32/win32.c (CreateChild): create process group to receive the
+ signal by GenerateConsoleCtrlEvent().
+
+ * win32/win32.c (kill): use CTRL_BREAK_EVENT instead of CTRL_C_EVENT
+ if a process group is specified. CTRL_C_EVENT signal cannot be
+ generated for process groups for the specification.
+ [ruby-dev:45149] [Bug #5812]
+
Sat Jan 28 07:46:03 2012 Hiroshi Shirosaki <h.shirosaki@gmail.com>
* thread_win32.c (rb_w32_wait_events_blocking): use
diff --git a/test/ruby/test_thread.rb b/test/ruby/test_thread.rb
index 0931de5659..6f7d1280bd 100644
--- a/test/ruby/test_thread.rb
+++ b/test/ruby/test_thread.rb
@@ -694,9 +694,14 @@ class TestThreadGroup < Test::Unit::TestCase
Process.kill(:SIGINT, pid)
Process.wait(pid)
s = $?
- assert_equal([false, true, false],
- [s.exited?, s.signaled?, s.stopped?],
- "[s.exited?, s.signaled?, s.stopped?]")
+ if /mswin|mingw/ =~ RUBY_PLATFORM
+ # status of signal is not supported on Windows
+ assert_equal(pid, s.pid)
+ else
+ assert_equal([false, true, false],
+ [s.exited?, s.signaled?, s.stopped?],
+ "[s.exited?, s.signaled?, s.stopped?]")
+ end
t1 = Time.now.to_f
assert_in_delta(t1 - t0, 1, 1)
end
diff --git a/win32/win32.c b/win32/win32.c
index 7cb1b31df6..9922fa5b14 100644
--- a/win32/win32.c
+++ b/win32/win32.c
@@ -1132,7 +1132,7 @@ CreateChild(const WCHAR *cmd, const WCHAR *prog, SECURITY_ATTRIBUTES *psa,
aStartupInfo.hStdError = GetStdHandle(STD_ERROR_HANDLE);
}
- dwCreationFlags = (NORMAL_PRIORITY_CLASS);
+ dwCreationFlags = (CREATE_NEW_PROCESS_GROUP | NORMAL_PRIORITY_CLASS);
if (lstrlenW(cmd) > 32767) {
child->pid = 0; /* release the slot */
@@ -4094,7 +4094,13 @@ kill(int pid, int sig)
case SIGINT:
RUBY_CRITICAL({
- if (!GenerateConsoleCtrlEvent(CTRL_C_EVENT, (DWORD)pid)) {
+ DWORD ctrlEvent = CTRL_C_EVENT;
+ if (pid != 0) {
+ /* CTRL+C signal cannot be generated for process groups.
+ * Instead, we use CTRL+BREAK signal. */
+ ctrlEvent = CTRL_BREAK_EVENT;
+ }
+ if (!GenerateConsoleCtrlEvent(ctrlEvent, (DWORD)pid)) {
if ((err = GetLastError()) == 0)
errno = EPERM;
else