--- IO.popen(command [, mode])
--- IO.popen(command [, mode]) {|io| ... }

    command 򥵥֥ץȤƼ¹ԤΥץɸ
    Ȥδ֤˥ѥץ饤Ωޤmode ϥץ󤹤 IO ݡ
    ȤΥ⡼ɤꤷޤ(mode ξܺ٤ open 
    )ά줿ȤΥǥեȤ "r" Ǥ

    ѥ(IO ֥)֤ޤ

        p io = IO.popen("cat", "r+")  # => #<IO:0x401b75c8>
        io.puts "foo"
        p io.gets  # => "foo\n"

    ֥åͿ줿 IO ֥Ȥ˥
    å¹Ԥη̤֤ޤ֥åμ¹Ը塢ѥ
    פϼưŪ˥ޤ

        p IO.popen("cat", "r+") {|io|
          io.puts "foo"
          io.gets
        }
        # => "foo\n"

    ޥ̾ "-" λRuby  fork(2) [manual page] 
    ԤҥץɸϤȤδ֤˥ѥץ饤ΩޤΤ
    ϡƥץ IO ֥Ȥ֤ҥץ
    nil ֤ޤ֥åСƥץ
    IO ֥Ȥ˥֥å¹Ԥη̤֤ޤ
    (ѥפϥޤ)
    ҥץ nil ˥֥å¹Ԥλޤ

       # ֥åʤ

       io = IO.popen("-", "r+")
       if io.nil?
         # child
         s = gets
         print "child output: " + s
         exit
       end

       # parent
       io.puts "foo"
       p io.gets                   # => "child output: foo\n"
       io.close

       # ֥å

       p IO.popen("-", "r+") {|io|
         if io
           # parent
           io.puts "foo"
           io.gets
         else
           # child
           s = gets
           puts "child output: " + s
         end
       }
       # => "child output: foo\n"

    ѥס뤤ϻҥץ˼Ԥ㳰 
    Errno::EXXX ȯޤ

