From: Kikutani Makoto Date: 1997-11-28T11:10:37+09:00 Subject: [ruby-list:5470] communicate with subprocess part II きくたにです。 またまたサブプロセスとの通信なのです。 ----- ipc1.rb ----- i = $stdin.read(4) i.each_byte {|byte| printf($stderr, "ipc1.rb: int byte = %x\n", byte) } $stdout.write("OK") s = $stdin.read(4) $stdout.write("OK") printf($stderr, "ipc1.rb: str = %s\n", s) ------------------- という子を ----- ipc-test1.rb ----- f = open("|./ipc1.rb", "r+") i = 0x12345678; f.write([i].pack("i")) printf($stderr, f.read(2), "\n") f.write("ruby") printf($stderr, f.read(2), "\n") ------------------------ の親で起動してやりとりしたいのですが、 % ruby ipc-test1.rb ipc1.rb: int byte = 78 ipc1.rb: int byte = 56 ipc1.rb: int byte = 34 ipc1.rb: int byte = 12 で終ってしまうです。子からの"OK"を親が受けとってくれない。 ruby - version 1.0-971021 (i586-linux) 質問その2: ipc-test1.rb のように双方向のパイプ(?)を作るのはPythonではできない そうですが、Cで書くにはどうすればいいのでしょうか? -- 人生を背負い投げ 菊谷 誠(Kikutani Makoto) kikutani@eis.or.jp kikutani@jdc.ericsson.se hgf03701@niftyserve.or.jp http://www.eis.or.jp/muse/kikutani/