HEX
Server: Apache
System: Linux vps-cdc32557.vps.ovh.ca 5.15.0-156-generic #166-Ubuntu SMP Sat Aug 9 00:02:46 UTC 2025 x86_64
User: hanode (1017)
PHP: 7.4.33
Disabled: pcntl_alarm,pcntl_fork,pcntl_waitpid,pcntl_wait,pcntl_wifexited,pcntl_wifstopped,pcntl_wifsignaled,pcntl_wifcontinued,pcntl_wexitstatus,pcntl_wtermsig,pcntl_wstopsig,pcntl_signal,pcntl_signal_get_handler,pcntl_signal_dispatch,pcntl_get_last_error,pcntl_strerror,pcntl_sigprocmask,pcntl_sigwaitinfo,pcntl_sigtimedwait,pcntl_exec,pcntl_getpriority,pcntl_setpriority,pcntl_async_signals,pcntl_unshare,
Upload Files
File: //usr/share/ri/3.0.0/system/IO/popen-c.ri
U:RDoc::AnyMethod[iI"
popen:ETI"IO::popen;TT:publico:RDoc::Markup::Document:@parts[o:RDoc::Markup::Paragraph;	[I"BRuns the specified command as a subprocess; the subprocess's ;TI"Astandard input and output will be connected to the returned ;TI"IO object.;To:RDoc::Markup::BlankLineo;
;	[I"EThe PID of the started process can be obtained by IO#pid method.;T@o;
;	[I"._cmd_ is a string or an array as follows.;T@o:RDoc::Markup::Verbatim;	[I"
cmd:
;TI"7  "-"                                      : fork
;TI"a  commandline                              : command line string which is passed to a shell
;TI"e  [env, cmdname, arg1, ..., opts]          : command name and zero or more arguments (no shell)
;TI"n  [env, [cmdname, argv0], arg1, ..., opts] : command name, argv[0] and zero or more arguments (no shell)
;TI""(env and opts are optional.)
;T:@format0o;
;	[I"0If _cmd_ is a +String+ ``<code>-</code>'', ;TI">then a new instance of Ruby is started as the subprocess.;T@o;
;	[	I".If <i>cmd</i> is an +Array+ of +String+, ;TI"Hthen it will be used as the subprocess's +argv+ bypassing a shell. ;TI"@The array can contain a hash at first for environments and ;TI"2a hash at last for options similar to #spawn.;T@o;
;	[I"8The default mode for the new file object is ``r'', ;TI"\but <i>mode</i> may be set to any of the modes listed in the description for class IO. ;TI"8The last argument <i>opt</i> qualifies <i>mode</i>.;T@o;;	[I"# set IO encoding
;TI"IIO.popen("nkf -e filename", :external_encoding=>"EUC-JP") {|nkf_io|
;TI"#  euc_jp_string = nkf_io.read
;TI"}
;TI"
;TI"6# merge standard output and standard error using
;TI"8# spawn option.  See the document of Kernel.spawn.
;TI":IO.popen(["ls", "/", :err=>[:child, :out]]) {|ls_io|
;TI")  ls_result_with_error = ls_io.read
;TI"}
;TI"
;TI"2# spawn options can be mixed with IO options
;TI":IO.popen(["ls", "/"], :err=>[:child, :out]) {|ls_io|
;TI")  ls_result_with_error = ls_io.read
;TI"}
;T;
0o;
;	[I"<Raises exceptions which IO.pipe and Kernel.spawn raise.;T@o;
;	[
I"IIf a block is given, Ruby will run the command as a child connected ;TI"Eto Ruby with a pipe. Ruby's end of the pipe will be passed as a ;TI"parameter to the block. ;TI"IAt the end of block, Ruby closes the pipe and sets <code>$?</code>. ;TI":In this case IO.popen returns the value of the block.;T@o;
;	[I"=If a block is given with a _cmd_ of ``<code>-</code>'', ;TI"Jthe block will be run in two separate processes: once in the parent, ;TI"Eand once in a child. The parent process will be passed the pipe ;TI"Hobject as a parameter to the block, the child version of the block ;TI";will be passed +nil+, and the child's standard in and ;TI"Hstandard out will be connected to the parent through the pipe. Not ;TI" available on all platforms.;T@o;;	[I"f = IO.popen("uname")
;TI"p f.readlines
;TI"
f.close
;TI"%puts "Parent is #{Process.pid}"
;TI")IO.popen("date") {|f| puts f.gets }
;TI"RIO.popen("-") {|f| $stderr.puts "#{Process.pid} is here, f is #{f.inspect}"}
;TI"
p $?
;TI">IO.popen(%w"sed -e s|^|<foo>| -e s&$&;zot;&", "r+") {|f|
;TI"0  f.puts "bar"; f.close_write; puts f.gets
;TI"}
;T;
0o;
;	[I"<em>produces:</em>;T@o;;	[I"["Linux\n"]
;TI"Parent is 21346
;TI""Thu Jan 15 22:41:19 JST 2009
;TI"$21346 is here, f is #<IO:fd 3>
;TI"21352 is here, f is nil
;TI"*#<Process::Status: pid 21352 exit 0>
;TI"<foo>bar;zot;;T;
0:
@fileI"	io.c;T:0@omit_headings_from_table_of_contents_below0I"|IO.popen([env,] cmd, mode="r" [, opt])               -> io
IO.popen([env,] cmd, mode="r" [, opt]) {|io| block } -> obj
;T0[I"(*args);T@jFI"IO;TcRDoc::NormalClass00