summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authornagachika <nagachika@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2013-10-04 16:25:39 +0000
committernagachika <nagachika@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2013-10-04 16:25:39 +0000
commitea2c9da96fc364f7b6a8f41e3304ae53d63d5cad (patch)
tree09ffa9d50d98e867f1c7a70ecbd8b57bdfbe2c0f /test
parent210efb5c3e6f7bad3b2651990a400f8d3d62ca5c (diff)
merge revision(s) 40534,41886,41903,41910: [Backport #8616]
process.c: rb_daemon should not raise * process.c (rb_daemon): should not raise exceptions, since proc_daemon() will deal with errors. * process.c (fork_daemon): kill the other threads all and abandon the kept mutexes. * process.c (fork_daemon): kill the other threads all and abandon the kept mutexes. * process.c (rb_daemon): daemon(3) is implemented with fork(2). Therefore it needs rb_thread_atfork(). (and revert r41903) git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_2_0_0@43142 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'test')
-rw-r--r--test/ruby/test_process.rb21
1 files changed, 21 insertions, 0 deletions
diff --git a/test/ruby/test_process.rb b/test/ruby/test_process.rb
index a70dca692e..c760e8ebda 100644
--- a/test/ruby/test_process.rb
+++ b/test/ruby/test_process.rb
@@ -1471,6 +1471,15 @@ class TestProcess < Test::Unit::TestCase
assert_equal("ok?\n", data)
end
+ def test_daemon_pid
+ cpid, dpid = IO.popen("-", "r+") do |f|
+ break f.pid, Integer(f.read) if f
+ Process.daemon(false, true)
+ puts $$
+ end
+ assert_not_equal(cpid, dpid)
+ end
+
if File.directory?("/proc/self/task") && /netbsd[a-z]*[1-6]/ !~ RUBY_PLATFORM
def test_daemon_no_threads
pid, data = IO.popen("-", "r+") do |f|
@@ -1482,6 +1491,18 @@ class TestProcess < Test::Unit::TestCase
assert_equal(2, data.size, bug4920)
assert_not_include(data.map(&:to_i), pid)
end
+ else # darwin
+ def test_daemon_no_threads
+ data = Timeout.timeout(3) do
+ IO.popen("-") do |f|
+ break f.readlines.map(&:chomp) if f
+ th = Thread.start {sleep 3}
+ Process.daemon(true, true)
+ puts Thread.list.size, th.status.inspect
+ end
+ end
+ assert_equal(["1", "false"], data)
+ end
end
end