Skip to content

Commit

Permalink
* test/ruby/test_thread.rb
Browse files Browse the repository at this point in the history
  (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 ruby#5812]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@34389 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
  • Loading branch information
shirosaki committed Jan 28, 2012
1 parent 494fd23 commit bb65920
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 5 deletions.
14 changes: 14 additions & 0 deletions ChangeLog
Original file line number Diff line number Diff line change
@@ -1,3 +1,17 @@
Sat Jan 28 08:18:11 2012 Hiroshi Shirosaki <[email protected]>

* 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 <[email protected]>

* thread_win32.c (rb_w32_wait_events_blocking): use
Expand Down
11 changes: 8 additions & 3 deletions test/ruby/test_thread.rb
Original file line number Diff line number Diff line change
Expand Up @@ -694,9 +694,14 @@ def test_thread_timer_and_interrupt
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
Expand Down
10 changes: 8 additions & 2 deletions win32/win32.c
Original file line number Diff line number Diff line change
Expand Up @@ -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 */
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit bb65920

Please sign in to comment.