mirror of
https://github.com/ruby/ruby.git
synced 2025-09-20 02:53:57 +02:00
* 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
This commit is contained in:
parent
dd91beb3e1
commit
706335aa0b
3 changed files with 68 additions and 9 deletions
|
@ -1,3 +1,8 @@
|
||||||
|
Fri Jun 24 17:06:33 2011 Nobuyoshi Nakada <nobu@ruby-lang.org>
|
||||||
|
|
||||||
|
* process.c (proc_daemon): should not start timer thread
|
||||||
|
twice. fixed Bug#4920.
|
||||||
|
|
||||||
Fri Jun 24 15:54:14 2011 Hiroshi Nakamura <nahi@ruby-lang.org>
|
Fri Jun 24 15:54:14 2011 Hiroshi Nakamura <nahi@ruby-lang.org>
|
||||||
|
|
||||||
* ext/openssl/ossl_ssl.c (ossl_ssl_shutdown): Try to shutdown SSL
|
* ext/openssl/ossl_ssl.c (ossl_ssl_shutdown): Try to shutdown SSL
|
||||||
|
|
18
process.c
18
process.c
|
@ -4806,10 +4806,7 @@ proc_setmaxgroups(VALUE obj, VALUE val)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if defined(HAVE_DAEMON) || (defined(HAVE_FORK) && defined(HAVE_SETSID))
|
#if defined(HAVE_DAEMON) || (defined(HAVE_FORK) && defined(HAVE_SETSID))
|
||||||
#ifndef HAVE_DAEMON
|
|
||||||
static int rb_daemon(int nochdir, int noclose);
|
static int rb_daemon(int nochdir, int noclose);
|
||||||
#define daemon(nochdir, noclose) rb_daemon((nochdir), (noclose))
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* call-seq:
|
* call-seq:
|
||||||
|
@ -4835,18 +4832,21 @@ proc_daemon(int argc, VALUE *argv)
|
||||||
rb_scan_args(argc, argv, "02", &nochdir, &noclose);
|
rb_scan_args(argc, argv, "02", &nochdir, &noclose);
|
||||||
|
|
||||||
prefork();
|
prefork();
|
||||||
before_fork();
|
n = rb_daemon(RTEST(nochdir), RTEST(noclose));
|
||||||
n = daemon(RTEST(nochdir), RTEST(noclose));
|
|
||||||
after_fork();
|
|
||||||
if (n < 0) rb_sys_fail("daemon");
|
if (n < 0) rb_sys_fail("daemon");
|
||||||
return INT2FIX(n);
|
return INT2FIX(n);
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifndef HAVE_DAEMON
|
|
||||||
static int
|
static int
|
||||||
rb_daemon(int nochdir, int noclose)
|
rb_daemon(int nochdir, int noclose)
|
||||||
{
|
{
|
||||||
int n, err = 0;
|
int err = 0;
|
||||||
|
#ifdef HAVE_DAEMON
|
||||||
|
before_fork();
|
||||||
|
err = daemon(nochdir, noclose);
|
||||||
|
after_fork();
|
||||||
|
#else
|
||||||
|
int n;
|
||||||
|
|
||||||
switch (rb_fork(0, 0, 0, Qnil)) {
|
switch (rb_fork(0, 0, 0, Qnil)) {
|
||||||
case -1:
|
case -1:
|
||||||
|
@ -4880,8 +4880,8 @@ rb_daemon(int nochdir, int noclose)
|
||||||
(void)close (n);
|
(void)close (n);
|
||||||
}
|
}
|
||||||
return err;
|
return err;
|
||||||
}
|
|
||||||
#endif
|
#endif
|
||||||
|
}
|
||||||
#else
|
#else
|
||||||
#define proc_daemon rb_f_notimplement
|
#define proc_daemon rb_f_notimplement
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -1268,4 +1268,58 @@ class TestProcess < Test::Unit::TestCase
|
||||||
ensure
|
ensure
|
||||||
Process.kill(:KILL, pid) if (pid != 0) rescue false
|
Process.kill(:KILL, pid) if (pid != 0) rescue false
|
||||||
end
|
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
|
end
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue