diff options
author | nagachika <nagachika@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2014-06-22 17:44:28 +0000 |
---|---|---|
committer | nagachika <nagachika@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2014-06-22 17:44:28 +0000 |
commit | 07ac36ada5a486023593d129b54be836923cfa4d (patch) | |
tree | e024087285333ecd9d1d5638be5b48e0c5317a79 /test/ruby | |
parent | b3cbe251735465520907cd07b3868e8128182ff7 (diff) |
merge revision(s) r45899: [Backport #9751]
* thread.c (thread_start_func_2): stop if forked in a sub-thread,
the thread has become the main thread.
[ruby-core:62070] [Bug #9751]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_2_1@46497 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'test/ruby')
-rw-r--r-- | test/ruby/test_thread.rb | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/test/ruby/test_thread.rb b/test/ruby/test_thread.rb index cd84c125bc..110bbdd6de 100644 --- a/test/ruby/test_thread.rb +++ b/test/ruby/test_thread.rb @@ -969,4 +969,25 @@ Thread.new(Thread.current) {|mth| pid, status = Process.waitpid2(pid) assert_equal(false, status.success?, bug8433) end if Process.respond_to?(:fork) + + def test_fork_in_thread + bug9751 = '[ruby-core:62070] [Bug #9751]' + f = nil + th = Thread.start do + unless f = IO.popen("-") + STDERR.reopen(STDOUT) + exit + end + Process.wait2(f.pid) + end + unless th.join(3) + Process.kill(:QUIT, f.pid) + Process.kill(:KILL, f.pid) unless th.join(1) + end + _, status = th.value + output = f.read + f.close + assert_not_predicate(status, :signaled?, FailDesc[status, bug9751, output]) + assert_predicate(status, :success?, bug9751) + end if Process.respond_to?(:fork) end |