diff options
author | usa <usa@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2014-01-30 11:46:03 +0000 |
---|---|---|
committer | usa <usa@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2014-01-30 11:46:03 +0000 |
commit | 1bd12d78c79c1194363f7755acab0a31109b935a (patch) | |
tree | 47987bcdbca56b2e8f1669e304e215d2d927e04b | |
parent | edd9ca9cd2760fd50ca9a51477b36e887510f476 (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_1_9_3@44766 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
-rw-r--r-- | ChangeLog | 15 | ||||
-rw-r--r-- | process.c | 25 | ||||
-rw-r--r-- | test/ruby/test_process.rb | 12 | ||||
-rw-r--r-- | version.h | 2 |
4 files changed, 37 insertions, 17 deletions
@@ -1,3 +1,18 @@ +Thu Jan 30 20:31:32 2014 NARUSE, Yui <naruse@ruby-lang.org> + + * process.c (rb_daemon): daemon(3) is implemented with fork(2). + Therefore it needs rb_thread_atfork(). (and revert r41903) + +Thu Jan 30 20:31:32 2014 Nobuyoshi Nakada <nobu@ruby-lang.org> + + * process.c (fork_daemon): kill the other threads all and abandon the + kept mutexes. + +Thu Jan 30 20:31:32 2014 Nobuyoshi Nakada <nobu@ruby-lang.org> + + * process.c (fork_daemon): kill the other threads all and abandon the + kept mutexes. + Thu Jan 30 19:54:16 2014 Nobuyoshi Nakada <nobu@ruby-lang.org> * gc.c (finalize_deferred): flush all deferred finalizers while other @@ -4918,26 +4918,19 @@ rb_daemon(int nochdir, int noclose) #else int n; - switch (rb_fork(0, 0, 0, Qnil)) { - case -1: - rb_sys_fail("daemon"); - case 0: - break; - default: - _exit(EXIT_SUCCESS); +#define fork_daemon() \ + switch (rb_fork(0, 0, 0, Qnil)) { \ + case -1: return -1; \ + case 0: break; \ + default: _exit(EXIT_SUCCESS); \ } - proc_setsid(); + fork_daemon(); + + if (setsid() < 0) return -1; /* must not be process-leader */ - switch (rb_fork(0, 0, 0, Qnil)) { - case -1: - return -1; - case 0: - break; - default: - _exit(EXIT_SUCCESS); - } + fork_daemon(); if (!nochdir) err = chdir("/"); diff --git a/test/ruby/test_process.rb b/test/ruby/test_process.rb index d1e2e1984d..83ff379ca9 100644 --- a/test/ruby/test_process.rb +++ b/test/ruby/test_process.rb @@ -1319,6 +1319,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 @@ -1,5 +1,5 @@ #define RUBY_VERSION "1.9.3" -#define RUBY_PATCHLEVEL 508 +#define RUBY_PATCHLEVEL 509 #define RUBY_RELEASE_DATE "2014-01-30" #define RUBY_RELEASE_YEAR 2014 |