/*
* call-seq:
* IO.popen(cmd_string, mode="r" ) => io
* IO.popen(cmd_string, mode="r" ) {|io| block } => obj
*
* Runs the specified command string as a subprocess; the subprocess's
* standard input and output will be connected to the returned
* <code>IO</code> object. If <i>cmd_string</i> starts with a
* ``<code>-</code>'', then a new instance of Ruby is started as the
* subprocess. The default mode for the new file object is ``r'', but
* <i>mode</i> may be set to any of the modes listed in the description
* for class IO.
*
* If a block is given, Ruby will run the command as a child connected
* to Ruby with a pipe. Ruby's end of the pipe will be passed as a
* parameter to the block. In this case <code>IO::popen</code> returns
* the value of the block.
*
* If a block is given with a <i>cmd_string</i> of ``<code>-</code>'',
* the block will be run in two separate processes: once in the parent,
* and once in a child. The parent process will be passed the pipe
* object as a parameter to the block, the child version of the block
* will be passed <code>nil</code>, and the child's standard in and
* standard out will be connected to the parent through the pipe. Not
* available on all platforms.
*
* f = IO.popen("uname")
* p f.readlines
* puts "Parent is #{Process.pid}"
* IO.popen ("date") { |f| puts f.gets }
* IO.popen("-") {|f| $stderr.puts "#{Process.pid} is here, f is #{f}"}
*
* <em>produces:</em>
*
* ["Linux\n"]
* Parent is 26166
* Wed Apr 9 08:53:52 CDT 2003
* 26169 is here, f is
* 26166 is here, f is #<IO:0x401b3d44>
*/
static VALUE
rb_io_s_popen(argc, argv, klass)
int argc;
VALUE *argv;
VALUE klass;
{
char *str = 0;
if (argc >= 1) {
str = StringValuePtr(argv[0]);
}
return rb_io_popen(str, argc, argv, klass);
}