[#28402] crypt — Kenji Noda <zaq94465a@...>

野田です

58 messages 2001/03/01
[#28404] Re: crypt — gotoken@... (GOTO Kentaro) 2001/03/01

In message "[ruby-list:28402] crypt"

[#28410] Re: crypt — "Akinori MUSHA" <knu@...> 2001/03/02

At Fri, 2 Mar 2001 04:34:52 +0900,

[#28413] Re: crypt — "丹生 光則 Nibu,Mitsunori." <nibu@...> 2001/03/02

newです.

[#28419] Re: crypt — matz@... (Yukihiro Matsumoto) 2001/03/02

まつもと ゆきひろです

[#28421] Re: crypt — gotoken@... (GOTO Kentaro) 2001/03/02

ごとけんです

[#28424] Re: crypt — "丹生 光則 Nibu,Mitsunori." <nibu@...> 2001/03/02

newです.

[#28435] ruby 1.6.3? — akira yamada / やまだあきら <akira@...>

24 messages 2001/03/02
[#28440] Re: ruby 1.6.3? — matz@... (Yukihiro Matsumoto) 2001/03/02

まつもと ゆきひろです

[#28572] Re: ruby 1.6.3? — akira yamada / やまだあきら <akira@...> 2001/03/07

[#28621] Re: ruby 1.6.3? — akira yamada / やまだあきら <akira@...> 2001/03/09

[#28624] Re: ruby 1.6.3? — matz@... (Yukihiro Matsumoto) 2001/03/09

まつもと ゆきひろです

[#28821] Re: ruby 1.6.3? — akira yamada / やまだあきら <akira@...> 2001/03/17

[#28823] Re: ruby 1.6.3? — matz@... (Yukihiro Matsumoto) 2001/03/17

まつもと ゆきひろです

[#28829] Re: ruby 1.6.3? — Kazuhiro Yoshida <moriq.kazuhiro@...> 2001/03/18

もりきゅうです。

[#28831] Re: ruby 1.6.3? — Kazuhiro Yoshida <moriq.kazuhiro@...> 2001/03/18

もりきゅうです。

[#28454] Ruby 初心者は! — 有瀬 和徳 <crush@...>

Kazunori Aruse

17 messages 2001/03/03

[#28485] ruby/tk TkEntry#selection_present bug? — Noritsugu Nakamura <nnakamur@...>

22 messages 2001/03/04
[#28492] Re: ruby/tk TkEntry#selection_present bug? — Koji Arai <JCA02266@...> 2001/03/04

新井です。

[#28559] Re: ruby/tk TkEntry#selection_present bug? — nagai@... 2001/03/06

永井@知能.九工大です.

[#28562] Re: ruby/tk TkEntry#selection_present bug? — Noritsugu Nakamura <nnakamur@...> 2001/03/06

[#28615] Re: ruby/tk TkEntry#selection_present bug? — nagai@... 2001/03/09

永井@知能.九工大です.

[#28530] テキストファイルを固定文字数で切って、行番号をつけるプログラム — Keisuke Minami <keisuke@...>

こんばんは。三並です。

10 messages 2001/03/05

[#28599] 1.6 のダウンロードマニュアルが圧縮されていない? — Keisuke Minami <keisuke@...>

こんばんは。三並です。

71 messages 2001/03/08
[#28601] Re: 1.6 のダウンロードマニュアルが圧縮されていない? — rubikitch <rubikitch@...> 2001/03/08

From: Keisuke Minami <keisuke@rccn.com>

[#28602] Re: 1.6 のダウンロードマニュアルが圧縮されていない? — SHIBATA Hiroshi <h-sbt@...9.so-net.ne.jp> 2001/03/08

 SHIBATA Hiroshiです。

[#28603] Re: 1.6 のダウンロードマニュアルが圧縮されていない? — gotoken@... (GOTO Kentaro) 2001/03/08

In message "[ruby-list:28602] Re: 1.6 のダウンロードマニュアルが圧縮されていない?"

[#28606] Ruby 1.6.2 リファレンスマニュアル — rubikitch <rubikitch@...> 2001/03/08

From: Keisuke Minami <keisuke@rccn.com>

[#28617] Re: Ruby 1.6.2 リファレンスマニュアル — "丹生 光則 Nibu,Mitsunori." <nibu@...> 2001/03/09

newです.

[#28618] Re: Ruby 1.6.2 リファレンスマニュアル — rubikitch <rubikitch@...> 2001/03/09

From: "丹生 光則 Nibu,Mitsunori." <nibu@tec.osaka.jip.co.jp>

[#28622] Re: Ruby 1.6.2 リファレンスマニュアル — "丹生 光則 Nibu,Mitsunori." <nibu@...> 2001/03/09

newです.

[#28644] Re: Ruby 1.6.2 リファレンスマニュアル — Daisuke Aoki <dai@...> 2001/03/09

青木@横浜です。

[#28672] Re: Ruby 1.6.2 リファレンスマニュアル — rubikitch <rubikitch@...> 2001/03/10

From: Daisuke Aoki <dai@sweetparty.ne.jp>

[#28705] Re: Ruby 1.6.2 リファレンスマニュアル — Daisuke Aoki <dai@...> 2001/03/12

青木@横浜です。

[#28697] Re: Ruby 1.6.2 リファレンスマニュアル — Daisuke Aoki <dai@...> 2001/03/12

青木@横浜です。

[#28773] [Q] ChibiXML のサンプルみたいなもの — eda@...

えだです。

14 messages 2001/03/15
[#28782] Re: [Q] ChibiXML のサンプルみたいなもの — TAKAHASHI Masayoshi <maki@...> 2001/03/16

高橋征義です。

[#28852] Re: [ruby-ext:01642] Re: o_dbm — keiju@... (石塚圭樹)

けいじゅ@日本ラショナルソフトウェアです.

17 messages 2001/03/19
[#29368] Re: [ruby-ext:01642] Re: o_dbm — akira yamada / やまだあきら <akira@...> 2001/04/21

[#29431] Re: [ruby-ext:01642] Re: o_dbm — keiju@... (石塚圭樹) 2001/04/26

けいじゅ@日本ラショナルソフトウェアです.

[#29468] Re: [ruby-ext:01642] Re: o_dbm — akira yamada / やまだあきら <akira@...> 2001/05/01

[#28911] media watch 2001.03.22 — akira yamada / やまだあきら <akira@...>

27 messages 2001/03/22
[#28955] Re: media watch 2001.03.22 — Keisuke Minami <keisuke@...> 2001/03/24

こんばんは。三並です。

[#28974] Re: media watch 2001.03.22 — akira yamada / やまだあきら <akira@...> 2001/03/26

[#28993] Re: media watch 2001.03.22 — Noritsugu Nakamura <nnakamur@...> 2001/03/27

[#29023] 配列に要素を挿入 — Kenji Noda <zaq94465a@...>

野田と申します

15 messages 2001/03/30

[#29037] forwardable-1.0 release — keiju@... (Keiju ISHITSUKA)

けいじゅ@日本ラショナルソフトウェアです.

25 messages 2001/03/30
[#29038] Re: forwardable-1.0 release — Toshiro Kuwabara <toshirok@...3.so-net.ne.jp> 2001/03/30

Toshです。

[#29042] Re: forwardable-1.0 release — matz@... (Yukihiro Matsumoto) 2001/03/31

まつもと ゆきひろです

[#29047] Re: forwardable-1.0 release — Toshiro Kuwabara <toshirok@...3.so-net.ne.jp> 2001/03/31

Toshです。

[#29057] Re: forwardable-1.0 release — keiju@... (石塚圭樹) 2001/04/02

けいじゅ@日本ラショナルソフトウェアです.

[#29060] Re: forwardable-1.0 release — Toshiro Kuwabara <toshirok@...3.so-net.ne.jp> 2001/04/02

Toshです。

[ruby-list:28396] Re: question of pipe , thread and queue

From: keiju@... (石塚圭樹)
Date: 2001-03-01 12:20:59 UTC
List: ruby-list #28396
けいじゅ@日本ラショナルソフトウェアです.

In [ruby-list :28241 ] the message: "[ruby-list:28241] Re: question of
pipe , thread and queue ", on Feb/25 00:35(JST) Yukihiro Matsumoto
writes:

>まつもと ゆきひろです

>|>たぶん、threadとforkを組み合わせてるのがイカンのでは?
>|>現在disableにしてる fork_and_kill_other_threads を on にする
>|>とこの問題は発生しないようです。
>|
>|うぅ. デフォルトの動作はこれじゃなかったんでしたっけ? 
>
>違います。いろいろモメたので。

うーん. どうなんですかねぇ... 今回のようにIOをポーリングしているスレッド
があると必ず問題になりますし. ライブラリを使う側がライブラリのスレッドが
勝手にやっていることの責任まで持つのはどうかと思うのですが...

でも, close-on-exec何かとの対称性から言えばこのままで良いのかしら... こ
れもforkする側が責任を持ってやれってことですからね...

>|良く考えたら, 必要ないIOをクローズしていないんですね. それではちょっと行
>|儀が悪いかなと... 過去のMLにもこの話題がありましたが, 推薦解がよくわかり
>|ませんでした. 推薦解としてはどういうものがあるでしょう?
>
>いまんとこ、決定打はないように思います。

簡単に, close-on-exec(じゃないもの)を指定できるインターフェイスが欲しい
ですね.

IO.set_all_close_on_exec_except(STDIO,...)

とか. または, openしているioをすべて取り出すインターフェイスがあっても良
いですが...

IO.set_close_on_exec(IO.all_open - [STDIO, ...])

それはそれでもんだいなんですが. ともかく. 

例のやつダイブできたのですがまた問題が発生しています.

最後に添付したプログラムで

% ruby pipe-sample.rb 2

とすると. ls|sort|head するのですが, 時々同じファイル名を複数返してきま
す... どう見てもプログラムのせいではないと思えるんですよね.

ちなみに, 

% ruby pipe-sample.rb 2 p

でログをとると, 

1548:put<sort>->8:0[test-shell.rb.~1~]
1548:put<sort>->8:0[test-thread.rb]
1548:close<sort>
1548:get<sort><-4:0[Makefile]
1548:put<head>->10:0[Makefile]
1548:get<sort><-4:0[Makefile]
1548:get<sort><-4:1[Obsolate]

こんな感じで, sortからMakefileが2回返ってきています. 入力は1回しかないの
に...

いったいどうしてでしょう?

#--
require "thread"   

class TestShell 

  def initialize(com)
    @com = com
    @pipe_me_in, @pipe_peer_out = IO.pipe
    @pipe_peer_in, @pipe_me_out = IO.pipe
#    Tracer.on
    Thread.critical = true
    @pid = fork {
      Thread.critical = true
      Thread.list.each{|th| th.kill unless th.equal?(Thread.current)}
      print "#{$$}:start<#{@com}>\n" if PRINT

#      Thread.critical = true
#      @pipe_me_in.close
#      @pipe_me_out.close
      ObjectSpace.each_object(IO){|io| 
	if [@pipe_peer_in, @pipe_peer_out, STDIN, STDOUT, STDERR].include?(io)
	else
	  io.close unless io.closed?
	end
      }
	  
      STDIN.reopen(@pipe_peer_in)
      Tracer.off
      STDOUT.reopen(@pipe_peer_out)
      exec(com)
    }
#    Tracer.off
    @pipe_peer_in.close
    @pipe_peer_out.close
    Thread.critical = false
    Thread.start do
      begin
#	loop do
	Process.waitpid(@pid)
#	  return if Process.waitpid(@pid, Process::WNOHANG)
#	  sleep 0.2
#	end
      rescue Errno::ECHILD
      ensure
	if PRINT
	  Thread.critical = true
	  print "#{$$}:Finish<#{@com}>\n"
	  Thread.critical = false
	end
      end
    end


    @queue = Queue.new
    
    Thread.start do
      if PRINT
	Thread.critical = true
	print "#{$$}:pipe_in<#{@com}>#{@pipe_me_in.fileno}\n"
	Thread.critical = false
      end
      while l = @pipe_me_in.gets
	if PRINT
	  Thread.critical = true
	  print "#{$$}:get<#{@com}><-#{@pipe_me_in.fileno}:#{@queue.size}[#{l.chop}]\n"
	  Thread.critical = false
	end
	@queue.push l
      end
      if PRINT
	Thread.critical = true
	print "#{$$}:get<#{@com}>[END]\n"
	Thread.critical = false
      end
      @queue.push :EOF
    end
  end

  def each
    while (l = @queue.pop) != :EOF
      yield l
    end
  end

  def set_input(sh)
    @input = sh
    Thread.start do
      if PRINT
	Thread.critical = true
	print "#{$$}:pipe_out<#{@com}>#{@pipe_me_out.fileno}\n"
	Thread.critical = false
      end
      begin
	@input.each{|l| 
	  if PRINT
	    Thread.critical = true
	    print "#{$$}:put<#{@com}>->#{@pipe_me_out.fileno}:#{@queue.size}[#{l.chop}]\n"
	    Thread.critical = false
	  end
	  @pipe_me_out.print l
	}
      rescue Errno::EPIPE
      ensure
	if PRINT
	  Thread.critical = true
	  print "#{$$}:close<#{@com}>\n"
	  Thread.critical = false
	end
	@pipe_me_out.flush
	@pipe_me_out.close
      end
    end
  end
end

STDOUT.sync = true
Thread.abort_on_exception=true

if ARGV.include?("p")
  PRINT = true
else
  PRINT = false
end

require "tracer"
Tracer.add_filter do
  |event, file, line, id, binding|
  File::dirname(file) == "." or File::dirname(file) == "sample"
end
if ARGV.include?("t")
  Tracer.on
end

if ARGV.include?("1")
  ls = TestShell.new("ls")
  head = TestShell.new("head")
  #sleep 1
  head.set_input(ls)
  #sleep 1
  #p ls.instance_eval{@queue}
  for l in head
    print l
  end
end

if ARGV.include?("1s")
  ls = TestShell.new("ls")
  sort = TestShell.new("sort")
  #sleep 1
  sort.set_input(ls)
  #sleep 1
  #p ls.instance_eval{@queue}
  for l in sort
    print l
  end
end


if ARGV.include?("1u")
  ls = TestShell.new("ls")
  uniq = TestShell.new("uniq -d")
  #sleep 1
  uniq.set_input(ls)
  #sleep 1
  #p ls.instance_eval{@queue}
  for l in uniq
    print l
  end
end

if ARGV.include?("2")
  ls = TestShell.new("ls")
#  sleep 1
  sort = TestShell.new("sort")
  sort.set_input(ls)
#  sleep 0.4
  head = TestShell.new("head")
  head.set_input(sort)
  #p ls.instance_eval{@queue}
  for l in head
    print l
  end
end

if ARGV.include?("2ch")
  ls = TestShell.new("ls")
#  sleep 1
  cat = TestShell.new("cat")
  cat.set_input(ls)
#  sleep 0.4
  head = TestShell.new("head")
  head.set_input(cat)
  #p ls.instance_eval{@queue}
  for l in head
    print l
  end
end

if ARGV.include?("3")
  ls = TestShell.new("ls")
#  sleep 1
  cat = TestShell.new("cat")
  cat.set_input(ls)

  sort = TestShell.new("sort")
  sort.set_input(cat)
#  sleep 0.4
  head = TestShell.new("head")
  head.set_input(sort)
  #p ls.instance_eval{@queue}
  for l in head
    print l
  end
end

__
..............................石塚 圭樹@日本ラショナルソフトウェア...
----------------------------------->> e-mail: keiju@rational.com <<---

In This Thread