diff options
author | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2011-06-24 08:06:38 +0000 |
---|---|---|
committer | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2011-06-24 08:06:38 +0000 |
commit | 706335aa0beaf1477acc41e15543e412c760474e (patch) | |
tree | a8da4be2645f3b2188a6e23131f788d6a5017c21 /test/ruby | |
parent | dd91beb3e1e39fdee5588419fc0da8b09fd70a06 (diff) | |
download | ruby-706335aa0beaf1477acc41e15543e412c760474e.tar.gz |
* process.c (proc_daemon): should not start timer thread
twice. fixed Bug#4920.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@32221 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'test/ruby')
-rw-r--r-- | test/ruby/test_process.rb | 54 |
1 files changed, 54 insertions, 0 deletions
diff --git a/test/ruby/test_process.rb b/test/ruby/test_process.rb index 4df883fb53..aad043874e 100644 --- a/test/ruby/test_process.rb +++ b/test/ruby/test_process.rb @@ -1268,4 +1268,58 @@ class TestProcess < Test::Unit::TestCase ensure Process.kill(:KILL, pid) if (pid != 0) rescue false end + + if Process.respond_to?(:daemon) + def test_daemon_default + data = IO.popen("-", "r+") do |f| + break f.read if f + Process.daemon + puts "ng" + end + assert_equal("", data) + end + + def test_daemon_noclose + data = IO.popen("-", "r+") do |f| + break f.read if f + Process.daemon(false, true) + puts "ok", Dir.pwd + end + assert_equal("ok\n/\n", data) + end + + def test_daemon_nochdir_noclose + data = IO.popen("-", "r+") do |f| + break f.read if f + Process.daemon(true, true) + puts "ok", Dir.pwd + end + assert_equal("ok\n#{Dir.pwd}\n", data) + end + + def test_daemon_readwrite + data = IO.popen("-", "r+") do |f| + if f + f.puts "ok?" + break f.read + end + Process.daemon(true, true) + puts STDIN.gets + end + assert_equal("ok?\n", data) + end + + if File.directory?("/proc/self/task") + def test_daemon_no_threads + pid, data = IO.popen("-", "r+") do |f| + break f.pid, f.readlines if f + Process.daemon(true, true) + puts Dir.entries("/proc/self/task") - %W[. ..] + end + bug4920 = '[ruby-dev:43873]' + assert_equal(2, data.size, bug4920) + assert_not_include(data.map(&:to_i), pid) + end + end + end end |