[前][次][番号順一覧][スレッド一覧]

ruby-changes:32687

From: usa <ko1@a...>
Date: Thu, 30 Jan 2014 20:46:08 +0900 (JST)
Subject: [ruby-changes:32687] usa:r44766 (ruby_1_9_3): merge revision(s) 40534, 41886, 41903, 41910: [Backport #8616]

usa	2014-01-30 20:46:03 +0900 (Thu, 30 Jan 2014)

  New Revision: 44766

  http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=rev&revision=44766

  Log:
    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)

  Modified directories:
    branches/ruby_1_9_3/
  Modified files:
    branches/ruby_1_9_3/ChangeLog
    branches/ruby_1_9_3/process.c
    branches/ruby_1_9_3/test/ruby/test_process.rb
    branches/ruby_1_9_3/version.h
Index: ruby_1_9_3/ChangeLog
===================================================================
--- ruby_1_9_3/ChangeLog	(revision 44765)
+++ ruby_1_9_3/ChangeLog	(revision 44766)
@@ -1,3 +1,18 @@ https://github.com/ruby/ruby/blob/trunk/ruby_1_9_3/ChangeLog#L1
+Thu Jan 30 20:31:32 2014  NARUSE, Yui  <naruse@r...>
+
+	* 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@r...>
+
+	* process.c (fork_daemon): kill the other threads all and abandon the
+	  kept mutexes.
+
+Thu Jan 30 20:31:32 2014  Nobuyoshi Nakada  <nobu@r...>
+
+	* process.c (fork_daemon): kill the other threads all and abandon the
+	  kept mutexes.
+
 Thu Jan 30 19:54:16 2014  Nobuyoshi Nakada  <nobu@r...>
 
 	* gc.c (finalize_deferred): flush all deferred finalizers while other
Index: ruby_1_9_3/process.c
===================================================================
--- ruby_1_9_3/process.c	(revision 44765)
+++ ruby_1_9_3/process.c	(revision 44766)
@@ -4918,26 +4918,19 @@ rb_daemon(int nochdir, int noclose) https://github.com/ruby/ruby/blob/trunk/ruby_1_9_3/process.c#L4918
 #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("/");
Index: ruby_1_9_3/version.h
===================================================================
--- ruby_1_9_3/version.h	(revision 44765)
+++ ruby_1_9_3/version.h	(revision 44766)
@@ -1,5 +1,5 @@ https://github.com/ruby/ruby/blob/trunk/ruby_1_9_3/version.h#L1
 #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
Index: ruby_1_9_3/test/ruby/test_process.rb
===================================================================
--- ruby_1_9_3/test/ruby/test_process.rb	(revision 44765)
+++ ruby_1_9_3/test/ruby/test_process.rb	(revision 44766)
@@ -1319,6 +1319,18 @@ class TestProcess < Test::Unit::TestCase https://github.com/ruby/ruby/blob/trunk/ruby_1_9_3/test/ruby/test_process.rb#L1319
         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
 

Property changes on: ruby_1_9_3
___________________________________________________________________
Modified: svn:mergeinfo
   Merged /trunk:r40534,41903


--
ML: ruby-changes@q...
Info: http://www.atdot.net/~ko1/quickml/

[前][次][番号順一覧][スレッド一覧]