mirror of
https://github.com/ruby/ruby.git
synced 2025-09-18 10:03:59 +02:00
merge revision(s) 34040,34051,34063,34389,34402,34403:
------------------------------------------------------------------------ r34040 | naruse | 2011-12-14 14:42:34 +0900 (Wed, 14 Dec 2011) | 1 line Use pipe instead of $stdin.read. ------------------------------------------------------------------------ * test/ruby/envutil.rb (invoke_ruby): remove :timeout option before pass it to Kernel#spawn. * 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] * test/ruby/envutil.rb (EnvUtil.invoke_ruby): yield also child pid in block form. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_9_3@34426 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
5dc6d20cc3
commit
e892c81cb1
5 changed files with 51 additions and 13 deletions
24
ChangeLog
24
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>
|
Fri Feb 3 10:10:02 2012 CHIKANAGA Tomoyuki <nagachika00@gmail.com>
|
||||||
|
|
||||||
* thread_pthread.c (ping_signal_thread_list): remove return value.
|
* thread_pthread.c (ping_signal_thread_list): remove return value.
|
||||||
|
|
|
@ -42,6 +42,7 @@ module EnvUtil
|
||||||
out_p.set_encoding(enc) if out_p
|
out_p.set_encoding(enc) if out_p
|
||||||
err_p.set_encoding(enc) if err_p
|
err_p.set_encoding(enc) if err_p
|
||||||
end
|
end
|
||||||
|
timeout = opt.delete(:timeout) || 10
|
||||||
c = "C"
|
c = "C"
|
||||||
child_env = {}
|
child_env = {}
|
||||||
LANG_ENVS.each {|lc| child_env[lc] = c}
|
LANG_ENVS.each {|lc| child_env[lc] = c}
|
||||||
|
@ -54,13 +55,12 @@ module EnvUtil
|
||||||
out_c.close if capture_stdout
|
out_c.close if capture_stdout
|
||||||
err_c.close if capture_stderr && capture_stderr != :merge_to_stdout
|
err_c.close if capture_stderr && capture_stderr != :merge_to_stdout
|
||||||
if block_given?
|
if block_given?
|
||||||
return yield in_p, out_p, err_p
|
return yield in_p, out_p, err_p, pid
|
||||||
else
|
else
|
||||||
th_stdout = Thread.new { out_p.read } if capture_stdout
|
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
|
th_stderr = Thread.new { err_p.read } if capture_stderr && capture_stderr != :merge_to_stdout
|
||||||
in_p.write stdin_data.to_str
|
in_p.write stdin_data.to_str
|
||||||
in_p.close
|
in_p.close
|
||||||
timeout = opt.fetch(:timeout, 10)
|
|
||||||
if (!th_stdout || th_stdout.join(timeout)) && (!th_stderr || th_stderr.join(timeout))
|
if (!th_stdout || th_stdout.join(timeout)) && (!th_stderr || th_stderr.join(timeout))
|
||||||
stdout = th_stdout.value if capture_stdout
|
stdout = th_stdout.value if capture_stdout
|
||||||
stderr = th_stderr.value if capture_stderr && capture_stderr != :merge_to_stdout
|
stderr = th_stderr.value if capture_stderr && capture_stderr != :merge_to_stdout
|
||||||
|
|
|
@ -689,15 +689,23 @@ class TestThreadGroup < Test::Unit::TestCase
|
||||||
def test_thread_timer_and_interrupt
|
def test_thread_timer_and_interrupt
|
||||||
bug5757 = '[ruby-dev:44985]'
|
bug5757 = '[ruby-dev:44985]'
|
||||||
t0 = Time.now.to_f
|
t0 = Time.now.to_f
|
||||||
pid = spawn(EnvUtil.rubybin, '-e', '$stdin.read')
|
pid = nil
|
||||||
sleep 1;
|
cmd = 'r,=IO.pipe; Thread.start {Thread.pass until Thread.main.stop?; puts; STDOUT.flush}; r.read'
|
||||||
Process.kill(:SIGQUIT, pid)
|
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)
|
Process.wait(pid)
|
||||||
s = $?
|
[$?, err_p.read]
|
||||||
assert_equal([false, true, false],
|
end
|
||||||
[s.exited?, s.signaled?, s.stopped?],
|
|
||||||
"[s.exited?, s.signaled?, s.stopped?]")
|
|
||||||
t1 = Time.now.to_f
|
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)
|
assert_in_delta(t1 - t0, 1, 1)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
#define RUBY_VERSION "1.9.3"
|
#define RUBY_VERSION "1.9.3"
|
||||||
#define RUBY_PATCHLEVEL 30
|
#define RUBY_PATCHLEVEL 31
|
||||||
|
|
||||||
#define RUBY_RELEASE_DATE "2012-02-03"
|
#define RUBY_RELEASE_DATE "2012-02-03"
|
||||||
#define RUBY_RELEASE_YEAR 2012
|
#define RUBY_RELEASE_YEAR 2012
|
||||||
|
|
|
@ -1058,7 +1058,7 @@ CreateChild(const WCHAR *cmd, const WCHAR *prog, SECURITY_ATTRIBUTES *psa,
|
||||||
aStartupInfo.hStdError = GetStdHandle(STD_ERROR_HANDLE);
|
aStartupInfo.hStdError = GetStdHandle(STD_ERROR_HANDLE);
|
||||||
}
|
}
|
||||||
|
|
||||||
dwCreationFlags = (NORMAL_PRIORITY_CLASS);
|
dwCreationFlags = (CREATE_NEW_PROCESS_GROUP | NORMAL_PRIORITY_CLASS);
|
||||||
|
|
||||||
if (lstrlenW(cmd) > 32767) {
|
if (lstrlenW(cmd) > 32767) {
|
||||||
child->pid = 0; /* release the slot */
|
child->pid = 0; /* release the slot */
|
||||||
|
@ -3851,7 +3851,13 @@ kill(int pid, int sig)
|
||||||
|
|
||||||
case SIGINT:
|
case SIGINT:
|
||||||
RUBY_CRITICAL({
|
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)
|
if ((err = GetLastError()) == 0)
|
||||||
errno = EPERM;
|
errno = EPERM;
|
||||||
else
|
else
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue