summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorusa <usa@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2015-08-17 08:13:33 +0000
committerusa <usa@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2015-08-17 08:13:33 +0000
commitbd929bb48aa0daa237cbda73bef33c0c6adc75fd (patch)
treeec00215c9585e6350119f18be8e8ccf8d5d001f3
parent510bdd1502aae4f154af20a390c83578b866fd20 (diff)
merge revision(s) 51202,51203,51204: [Backport #11340]
* win32/win32.c (waitpid): return immediately if interrupted. reported by <takkanm AT gmail.com> [ruby-dev:49176] [Bug #11340] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_2_1@51607 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
-rw-r--r--ChangeLog5
-rw-r--r--test/ruby/test_process.rb23
-rw-r--r--version.h2
-rw-r--r--win32/win32.c4
4 files changed, 32 insertions, 2 deletions
diff --git a/ChangeLog b/ChangeLog
index dcc15e3b86..45746c2e86 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+Mon Aug 17 17:12:46 2015 NAKAMURA Usaku <usa@ruby-lang.org>
+
+ * win32/win32.c (waitpid): return immediately if interrupted.
+ reported by <takkanm AT gmail.com> [ruby-dev:49176] [Bug #11340]
+
Mon Aug 17 17:09:02 2015 Nobuyoshi Nakada <nobu@ruby-lang.org>
* parse.y (lambda_body): pop cmdarg stack for lookahead
diff --git a/test/ruby/test_process.rb b/test/ruby/test_process.rb
index a71a2d6dce..6bec5ba4cc 100644
--- a/test/ruby/test_process.rb
+++ b/test/ruby/test_process.rb
@@ -1263,6 +1263,29 @@ class TestProcess < Test::Unit::TestCase
end
end
+ def test_wait_exception
+ bug11340 = '[ruby-dev:49176] [Bug #11340]'
+ t0 = t1 = nil
+ IO.popen([RUBY, '-e', 'puts;STDOUT.flush;Thread.start{gets;exit};sleep(3)'], 'r+') do |f|
+ pid = f.pid
+ f.gets
+ t0 = Time.now
+ th = Thread.start(Thread.current) do |main|
+ Thread.pass until main.stop?
+ main.raise Interrupt
+ end
+ begin
+ assert_raise(Interrupt) {Process.wait(pid)}
+ ensure
+ th.kill.join
+ end
+ t1 = Time.now
+ f.puts
+ end
+ assert_operator(t1 - t0, :<, 3,
+ ->{"#{bug11340}: #{t1-t0} seconds to interrupt Process.wait"})
+ end
+
def test_abort
with_tmpchdir do
s = run_in_child("abort")
diff --git a/version.h b/version.h
index a30f0af3f5..3610f535f0 100644
--- a/version.h
+++ b/version.h
@@ -1,6 +1,6 @@
#define RUBY_VERSION "2.1.7"
#define RUBY_RELEASE_DATE "2015-08-17"
-#define RUBY_PATCHLEVEL 389
+#define RUBY_PATCHLEVEL 390
#define RUBY_RELEASE_YEAR 2015
#define RUBY_RELEASE_MONTH 8
diff --git a/win32/win32.c b/win32/win32.c
index 203e21b09f..f19c097abd 100644
--- a/win32/win32.c
+++ b/win32/win32.c
@@ -4265,7 +4265,9 @@ waitpid(rb_pid_t pid, int *stat_loc, int options)
while (!(pid = poll_child_status(child, stat_loc))) {
/* wait... */
- if (rb_w32_wait_events_blocking(&child->hProcess, 1, timeout) != WAIT_OBJECT_0) {
+ int ret = rb_w32_wait_events_blocking(&child->hProcess, 1, timeout);
+ if (ret == WAIT_OBJECT_0 + 1) return -1; /* maybe EINTR */
+ if (ret != WAIT_OBJECT_0) {
/* still active */
if (options & WNOHANG) {
pid = 0;