summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ChangeLog24
-rw-r--r--test/ruby/envutil.rb4
-rw-r--r--test/ruby/test_thread.rb24
-rw-r--r--version.h2
-rw-r--r--win32/win32.c10
5 files changed, 51 insertions, 13 deletions
diff --git a/ChangeLog b/ChangeLog
index 395cf11280..fb378b42ec 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,27 @@
+Fri Feb 3 16:16:10 2012 Nobuyoshi Nakada <nobu@ruby-lang.org>
+
+ * test/ruby/envutil.rb (EnvUtil.invoke_ruby): yield also child pid
+ in block form.
+
+Fri Feb 3 16:16:10 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]
+
+Fri Feb 3 16:16:10 2012 CHIKANAGA Tomoyuki <nagachika00@gmail.com>
+
+ * test/ruby/envutil.rb (invoke_ruby): remove :timeout option before
+ pass it to Kernel#spawn.
+
Fri Feb 3 10:10:02 2012 CHIKANAGA Tomoyuki <nagachika00@gmail.com>
* thread_pthread.c (ping_signal_thread_list): remove return value.
diff --git a/test/ruby/envutil.rb b/test/ruby/envutil.rb
index 4a8451a9de..ef5f65c747 100644
--- a/test/ruby/envutil.rb
+++ b/test/ruby/envutil.rb
@@ -42,6 +42,7 @@ module EnvUtil
out_p.set_encoding(enc) if out_p
err_p.set_encoding(enc) if err_p
end
+ timeout = opt.delete(:timeout) || 10
c = "C"
child_env = {}
LANG_ENVS.each {|lc| child_env[lc] = c}
@@ -54,13 +55,12 @@ module EnvUtil
out_c.close if capture_stdout
err_c.close if capture_stderr && capture_stderr != :merge_to_stdout
if block_given?
- return yield in_p, out_p, err_p
+ return yield in_p, out_p, err_p, pid
else
th_stdout = Thread.new { out_p.read } if capture_stdout
th_stderr = Thread.new { err_p.read } if capture_stderr && capture_stderr != :merge_to_stdout
in_p.write stdin_data.to_str
in_p.close
- timeout = opt.fetch(:timeout, 10)
if (!th_stdout || th_stdout.join(timeout)) && (!th_stderr || th_stderr.join(timeout))
stdout = th_stdout.value if capture_stdout
stderr = th_stderr.value if capture_stderr && capture_stderr != :merge_to_stdout
diff --git a/test/ruby/test_thread.rb b/test/ruby/test_thread.rb
index 209d4b006f..589ae7a899 100644
--- a/test/ruby/test_thread.rb
+++ b/test/ruby/test_thread.rb
@@ -689,15 +689,23 @@ class TestThreadGroup < Test::Unit::TestCase
def test_thread_timer_and_interrupt
bug5757 = '[ruby-dev:44985]'
t0 = Time.now.to_f
- pid = spawn(EnvUtil.rubybin, '-e', '$stdin.read')
- sleep 1;
- Process.kill(:SIGQUIT, pid)
- Process.wait(pid)
- s = $?
- assert_equal([false, true, false],
- [s.exited?, s.signaled?, s.stopped?],
- "[s.exited?, s.signaled?, s.stopped?]")
+ pid = nil
+ cmd = 'r,=IO.pipe; Thread.start {Thread.pass until Thread.main.stop?; puts; STDOUT.flush}; r.read'
+ s, err = EnvUtil.invoke_ruby(['-e', cmd], "", true, true) do |in_p, out_p, err_p, cpid|
+ out_p.gets
+ pid = cpid
+ Process.kill(:SIGINT, pid)
+ Process.wait(pid)
+ [$?, err_p.read]
+ end
t1 = Time.now.to_f
+ assert_equal(pid, s.pid)
+ unless /mswin|mingw/ =~ RUBY_PLATFORM
+ # status of signal is not supported on Windows
+ assert_equal([false, true, false, Signal.list["INT"]],
+ [s.exited?, s.signaled?, s.stopped?, s.termsig],
+ "[s.exited?, s.signaled?, s.stopped?, s.termsig]")
+ end
assert_in_delta(t1 - t0, 1, 1)
end
end
diff --git a/version.h b/version.h
index ae945241e4..786098d201 100644
--- a/version.h
+++ b/version.h
@@ -1,5 +1,5 @@
#define RUBY_VERSION "1.9.3"
-#define RUBY_PATCHLEVEL 30
+#define RUBY_PATCHLEVEL 31
#define RUBY_RELEASE_DATE "2012-02-03"
#define RUBY_RELEASE_YEAR 2012
diff --git a/win32/win32.c b/win32/win32.c
index 908730bbec..759762b89a 100644
--- a/win32/win32.c
+++ b/win32/win32.c
@@ -1058,7 +1058,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 */
@@ -3851,7 +3851,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