[#43610] Re: [ruby-list:48149] Re: requireが配列を取れたら便利だと思うんだけど.. — Hiroshi Nakamura <nakahiro@...>

ruby-listから持って来ました。でも続かなそう。

12 messages 2011/06/02

[#43643] DateTime.new! and DateTime.jd — Aaron Patterson <aaron.patterson@...>

こんにちは、アーロンです。

25 messages 2011/06/07
[#43647] Re: DateTime.new! and DateTime.jd — Tadayoshi Funaba <tadf@...> 2011/06/07

blocker はお前だろ。

[#43648] Re: DateTime.new! and DateTime.jd — Yukihiro Matsumoto <matz@...> 2011/06/07

まつもと ゆきひろです

[#43651] Re: DateTime.new! and DateTime.jd — Tadayoshi Funaba <tadf@...> 2011/06/07

> うーん、ただでさえ日英のコミュニケーション障壁があるのに、よ

[#43653] Re: DateTime.new! and DateTime.jd — Aaron Patterson <aaron.patterson@...> 2011/06/07

2011/6/7 Tadayoshi Funaba <tadf@dotrb.org>:

[#43657] Re: DateTime.new! and DateTime.jd — Tadayoshi Funaba <tadf@...> 2011/06/07

皆さんってのに俺は入ってないみたいだな。

[#43661] Re: DateTime.new! and DateTime.jd — Yukihiro Matsumoto <matz@...> 2011/06/07

まつもと ゆきひろです

[#43662] Re: DateTime.new! and DateTime.jd — Tadayoshi Funaba <tadf@...> 2011/06/07

> Aaronが言ってる「リリース」は1.9.3のことだと思いますよ。

[#43645] Re: [ruby-core:36778] Re: 1.8.7 release next month — Urabe Shyouhei <shyouhei@...>

Moving to ruby-dev to understand strategies of backporting the Tk

13 messages 2011/06/07

[#43787] [Ruby 1.9 - Feature #4878][Open] CMath に frexp, ldexp, hypot の3関数は不要ではないか — Kenta Murata <muraken@...>

24 messages 2011/06/13
[#43788] Re: [Ruby 1.9 - Feature #4878][Open] CMath に frexp, ldexp, hypot の3関数は不要ではないか — Yukihiro Matsumoto <matz@...> 2011/06/13

まつもと ゆきひろです

[#43789] Re: [Ruby 1.9 - Feature #4878][Open] CMath に frexp, ldexp, hypot の3関数は不要ではないか — Tadayoshi Funaba <tadf@...> 2011/06/13

もう結論が出てしまったようですが、これは、元々 lib/complex.rb にあった

[#43794] Re: [Ruby 1.9 - Feature #4878][Open] CMath に frexp, ldexp, hypot の3関数は不要ではないか — Kenta Murata <muraken@...> 2011/06/13

むらたです。

[#43795] Re: [Ruby 1.9 - Feature #4878][Open] CMath に frexp, ldexp, hypot の3関数は不要ではないか — Tadayoshi Funaba <tadf@...> 2011/06/13

> complex.rb をロードすると Math が CMath 相当に置き換わりますから、

[#43797] Re: [Ruby 1.9 - Feature #4878][Open] CMath に frexp, ldexp, hypot の3関数は不要ではないか — Kenta Murata <muraken@...> 2011/06/14

むらたです。

[#43799] Re: [Ruby 1.9 - Feature #4878][Open] CMath に frexp, ldexp, hypot の3関数は不要ではないか — Yukihiro Matsumoto <matz@...> 2011/06/14

まつもと ゆきひろです

[#43800] Re: [Ruby 1.9 - Feature #4878][Open] CMath に frexp, ldexp, hypot の3関数は不要ではないか — Kenta Murata <muraken@...> 2011/06/14

むらたです。

[#43803] Re: [Ruby 1.9 - Feature #4878][Open] CMath に frexp, ldexp, hypot の3関数は不要ではないか — Tadayoshi Funaba <tadf@...> 2011/06/14

> これに相当する事をやっているのが complex.rb なので、

[#43806] Re: [Ruby 1.9 - Feature #4878][Open] CMath に frexp, ldexp, hypot の3関数は不要ではないか — Yusuke ENDOH <mame@...> 2011/06/14

遠藤です。

[#43807] Re: [Ruby 1.9 - Feature #4878][Open] CMath に frexp, ldexp, hypot の3関数は不要ではないか — Tadayoshi Funaba <tadf@...> 2011/06/14

> 定義域を増やすだけにしよう、ということですよね。賛成です。

[#43809] Re: [Ruby 1.9 - Feature #4878][Open] CMath に frexp, ldexp, hypot の3関数は不要ではないか — Yusuke ENDOH <mame@...> 2011/06/14

2011年6月14日22:17 Tadayoshi Funaba <tadf@dotrb.org>:

[#43810] Re: [Ruby 1.9 - Feature #4878][Open] CMath に frexp, ldexp, hypot の3関数は不要ではないか — Tadayoshi Funaba <tadf@...> 2011/06/14

> 互換性がないという点では同じ話だと思うのですが……。

[#43811] Re: [Ruby 1.9 - Feature #4878][Open] CMath に frexp, ldexp, hypot の3関数は不要ではないか — Yusuke ENDOH <mame@...> 2011/06/14

2011年6月14日23:02 Tadayoshi Funaba <tadf@dotrb.org>:

[#43812] Re: [Ruby 1.9 - Feature #4878][Open] CMath に frexp, ldexp, hypot の3関数は不要ではないか — Tadayoshi Funaba <tadf@...> 2011/06/14

> いやあ、5 月末の feature freeze 時点では -2 を返していたはずなんですが、

[#43852] [Ruby 1.9 - Bug #4909][Open] trapハンドラは再入されてはいけないのではないか? — Motohiro KOSAKI <kosaki.motohiro@...>

11 messages 2011/06/20

[ruby-dev:43878] [Ruby 1.9 - Bug #4920] Process.daemon()呼び出しによりタイマースレッドが2つ出来てしまう

From: Motohiro KOSAKI <kosaki.motohiro@...>
Date: 2011-06-23 06:54:02 UTC
List: ruby-dev #43878
Issue #4920 has been updated by Motohiro KOSAKI.


直接の原因はこのコミットのようです。


commit afbd5661a0ca041ac818c9e5732911c5db21c9f9
Author: nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>
Date:   Tue Jul 13 12:31:17 2010 +0000

    * process.c (rb_daemon): split from proc_daemon.


    git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@28630 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
---
 process.c |   27 +++++++++++++++++++--------
 1 files changed, 19 insertions(+), 8 deletions(-)

diff --git a/process.c b/process.c
index 8e601ba..84fed60 100644
--- a/process.c
+++ b/process.c
@@ -4554,6 +4554,11 @@ proc_setmaxgroups(VALUE obj, VALUE val)
 }

 #if defined(HAVE_DAEMON) || (defined(HAVE_FORK) && defined(HAVE_SETSID))
+#ifndef HAVE_DAEMON
+static int rb_daemon(int nochdir, int noclose);
+#define daemon(nochdir, noclose) rb_daemon(nochdir, noclose)
+#endif
+
 /*
  *  call-seq:
  *     Process.daemon()                        -> 0
@@ -4577,14 +4582,20 @@ proc_daemon(int argc, VALUE *argv)
     rb_secure(2);
     rb_scan_args(argc, argv, "02", &nochdir, &noclose);

-#if defined(HAVE_DAEMON)
     prefork();
     before_fork();
     n = daemon(RTEST(nochdir), RTEST(noclose));
     after_fork();
     if (n < 0) rb_sys_fail("daemon");
     return INT2FIX(n);
-#elif defined(HAVE_FORK)
+}
+
+#ifndef HAVE_DAEMON
+static int
+rb_daemon(int nochdir, int noclose)
+{
+    int n, err = 0;
+
     switch (rb_fork(0, 0, 0, Qnil)) {
       case -1:
        rb_sys_fail("daemon");
@@ -4599,26 +4610,26 @@ proc_daemon(int argc, VALUE *argv)
     /* must not be process-leader */
     switch (rb_fork(0, 0, 0, Qnil)) {
       case -1:
-       rb_sys_fail("daemon");
+       return -1;
       case 0:
        break;
       default:
        _exit(EXIT_SUCCESS);
     }

-    if (!RTEST(nochdir))
-       (void)chdir("/");
+    if (!nochdir)
+       err = chdir("/");

-    if (!RTEST(noclose) && (n = open("/dev/null", O_RDWR, 0)) != -1) {
+    if (!noclose && (n = open("/dev/null", O_RDWR, 0)) != -1) {
        (void)dup2(n, 0);
        (void)dup2(n, 1);
        (void)dup2(n, 2);
        if (n > 2)
            (void)close (n);
     }
-    return INT2FIX(0);
-#endif
+    return err;
 }
+#endif
 #else
 #define proc_daemon rb_f_notimplement
 #endif
----------------------------------------
Bug #4920: Process.daemon()呼び出しによりタイマースレッドが2つ出来てしまう
http://redmine.ruby-lang.org/issues/4920

Author: Motohiro KOSAKI
Status: Assigned
Priority: High
Assignee: Motohiro KOSAKI
Category: core
Target version: 1.9.3
ruby -v: ruby 1.9.3dev (2011-06-19 trunk 32170) [x86_64-linux]


ささださんとakrさんが発見してくださったのですが、現在 trunkで

$ ./ruby -e 'Process.daemon(true,true); p Dir.entries("/proc/self/task")'

と実行すると、スレッドが3匹います(Linuxで実行してください)。何故かというと Process.daemon() 
を契機にタイマースレッドが2つ出来てしまうからです。

原因は以下のコードです

------------------------------------------------------
static VALUE
proc_daemon(int argc, VALUE *argv)
{
    VALUE nochdir, noclose;
    int n;

    rb_secure(2);
    rb_scan_args(argc, argv, "02", &nochdir, &noclose);

    prefork();
    before_fork();
    n = daemon(RTEST(nochdir), RTEST(noclose));
    after_fork();
    if (n < 0) rb_sys_fail("daemon");
    return INT2FIX(n);
}
------------------------------------------------------

BSD以外の環境ではdaemon()はOSのdaemon(3)ではなく、rb_daemon()を使用し、
rb_daemonは内部的にrb_fork_err()を使用するため結果的に

    before_fork();
    before_fork();
    fork();
    after_fork();
    after_fork();

という呼び出し順序になり、after_fork()のたびにタイマースレッドをつくるので合計2スレッド。

もちろん、1.9.2ではちゃんと動くのでこれはリグレッションです。
さすがに、これはダメだろうと思うので時期が時期だけに恐縮ですがターゲットを1.9.3に
設定させていただきます。




-- 
http://redmine.ruby-lang.org

In This Thread