[#29987] ライセンス論点整理 — Tacos <ozaki@...>

38 messages 2001/06/01

[#30030] Ruby license discussion — Masayuki Hatta <mhatta@...>

八田と申します。

23 messages 2001/06/02
[#30034] Re: Ruby license discussion — "Akinori MUSHA" <knu@...> 2001/06/02

At Sat, 2 Jun 2001 14:31:02 +0900,

[#30039] Re: Ruby license discussion — akira yamada / やまだあきら <akira@...> 2001/06/02

[#30056] Re: Ruby license discussion — Takaaki Higuchi <thiguchi@...> 2001/06/03

In "akira yamada / やまだあきら <akira@ruby-lang.org>" wrote:

[#30155] How do we treat local static variables? — IKEGAMI Daisuke <daisu-ik@...>

ruby-list の皆さんこんにちは。

13 messages 2001/06/09
[#30156] Re: How do we treat local static variables? — NISHI Takao <zophos@...9.com> 2001/06/09

にし@おかやまです。

[#30163] FW: [arg1:119] RE: [RubyUnit:4203] Re: インストーラ・プロジェクト — "KANEMITSU Masao" <masao-k@...>

金光です。RAAを改善しませんか?

10 messages 2001/06/10

[#30190] 呼び出し元のクラスを知る方法? — "Shin'ya Adzumi" <adzumi@...>

あづみです。

13 messages 2001/06/11

[#30215] パス文字列を操作するライブラリはありませんか? — "Kaoru Shirai" <shirai@...1jp.com>

 こんにちわ。常日頃 Ruby を愛用させて頂いております。

13 messages 2001/06/13

[#30270] setup.rb — rubikitch@...

るびきちです。

16 messages 2001/06/16
[#30291] Re: setup.rb — Minero Aoki <aamine@...> 2001/06/18

あおきです。すみません、見逃してました。

[#30292] Re: setup.rb — rubikitch <rubikitch@...> 2001/06/19

From: Minero Aoki <aamine@mx.edit.ne.jp>

[#30293] Re: setup.rb — TADA Tadashi <sho@...> 2001/06/19

ただただしです。

[#30305] TMarshal — rubikitch@...

るびきちです。

25 messages 2001/06/19

[#30333] 共同著作物の謎( re :ライセンス) — Tacos <ozaki@...>

13 messages 2001/06/20
[#30334] Re: 共同著作物の謎( re :ライセンス) — Tacos <ozaki@...> 2001/06/20

[ruby-list:30388] Re: 1.6.4 と open3

From: nobu.nakada@...
Date: 2001-06-28 07:45:01 UTC
List: ruby-list #30388
なかだです。

At Tue, 26 Jun 2001 12:57:33 +0900,
Toshihisa Tsuji <dayan-ml-ruby-list@inwonder.net> wrote:
> >open3は過去も今もプロセスのステータスを捨てているように思います。
> あ、そうだったんですか できたらステータスが帰ったほうがありがたいです

  ちょっと試してみました。パッチのほうが大きくなりそうなのでそ
のまま付けます。open3 したものがすべて close されたところで $?
が設定されます。


# Usage:
#	require "open3"
#
#	in, out, err = Open3.popen3('nroff -man')
#  or
#	include Open3
#	in, out, err = popen3('nroff -man')
#

module Open3
  class Sentinel
    Finalizer = proc {|id| ObjectSpace._id2ref(id).final}

    def initialize(pid, *files)
      sentinel = self
      @pid = pid
      @files = {}
      files.each do |f|
	@files[f] = f.method(:close)
	f.instance_eval {@sentinel = sentinel}
	def f.close
	  @sentinel.closed(self)
	end
      end
      ObjectSpace.define_finalizer(self, Finalizer)
    end

    def closed(io)
      close = @files.delete(io) or return
      close.call
      final if @files.empty?
    end

    def final
      # clean finalization.
      pid = @pid
      files = @files
      @pid = @files = nil
      ObjectSpace.undefine_finalizer(self)

      while io = files.shift do io[1].call end
      Process.waitpid(pid) if pid
    end
  end

  #[stdin, stdout, stderr] = popen3(command);
  def popen3(*cmd)
    pw = IO::pipe   # pipe[0] for read, pipe[1] for write
    pr = IO::pipe
    pe = IO::pipe

    pid = fork {
      # child
      pw[1].close
      STDIN.reopen(pw[0])
      pw[0].close

      pr[0].close
      STDOUT.reopen(pr[1])
      pr[1].close

      pe[0].close
      STDERR.reopen(pe[1])
      pe[1].close

      exec(*cmd)
      exit!
    }

    pw[0].close
    pr[1].close
    pe[1].close
    pi = [pw[1], pr[0], pe[0]]
    sentinel = Sentinel.new(pid, *pi)
    if defined? yield
      begin
	return yield(*pi)
      ensure
        sentinel.final
      end
    end
    pi
  end
  module_function :popen3
end

if $0 == __FILE__
  a = Open3.popen3("nroff -man")
  Thread.start do
    while line = gets
      a[0].print line
    end
    a[0].close
  end
  while line = a[1].gets
    print ":", line
  end
end


-- 
--- 僕の前にBugはない。
--- 僕の後ろにBugはできる。
    中田 伸悦

In This Thread