ruby-changes:22340
From: shirosaki <ko1@a...>
Date: Sat, 28 Jan 2012 09:51:54 +0900 (JST)
Subject: [ruby-changes:22340] shirosaki:r34389 (trunk): * test/ruby/test_thread.rb
shirosaki 2012-01-28 09:51:40 +0900 (Sat, 28 Jan 2012) New Revision: 34389 http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=rev&revision=34389 Log: * 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] Modified files: trunk/ChangeLog trunk/test/ruby/test_thread.rb trunk/win32/win32.c Index: ChangeLog =================================================================== --- ChangeLog (revision 34388) +++ ChangeLog (revision 34389) @@ -1,3 +1,17 @@ +Sat Jan 28 08:18:11 2012 Hiroshi Shirosaki <h.shirosaki@g...> + + * 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@g...> * thread_win32.c (rb_w32_wait_events_blocking): use Index: win32/win32.c =================================================================== --- win32/win32.c (revision 34388) +++ win32/win32.c (revision 34389) @@ -1132,7 +1132,7 @@ 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 @@ 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 Index: test/ruby/test_thread.rb =================================================================== --- test/ruby/test_thread.rb (revision 34388) +++ test/ruby/test_thread.rb (revision 34389) @@ -694,9 +694,14 @@ 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 -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/