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/Kernel/open-i.ri
U:RDoc::AnyMethod[iI"	open:ETI"Kernel#open;TF:publico:RDoc::Markup::Document:@parts[3o:RDoc::Markup::Paragraph;	[I"MCreates an IO object connected to the given stream, file, or subprocess.;To:RDoc::Markup::BlankLineo;
;	[I"OIf +path+ does not start with a pipe character (<code>|</code>), treat it ;TI"Kas the name of a file to open using the specified mode (defaulting to ;TI"
"r").;T@o;
;	[	I"KThe +mode+ is either a string or an integer.  If it is an integer, it ;TI"Pmust be bitwise-or of open(2) flags, such as File::RDWR or File::EXCL.  If ;TI"?it is a string, it is either "fmode", "fmode:ext_enc", or ;TI""fmode:ext_enc:int_enc".;T@o;
;	[I"QSee the documentation of IO.new for full documentation of the +mode+ string ;TI"directives.;T@o;
;	[I"NIf a file is being created, its initial permissions may be set using the ;TI"P+perm+ parameter.  See File.new and the open(2) and chmod(2) man pages for ;TI""a description of permissions.;T@o;
;	[I"IIf a block is specified, it will be invoked with the IO object as a ;TI"Gparameter, and the IO will be automatically closed when the block ;TI":terminates.  The call returns the value of the block.;T@o;
;	[	I"PIf +path+ starts with a pipe character (<code>"|"</code>), a subprocess is ;TI"Kcreated, connected to the caller by a pair of pipes.  The returned IO ;TI"Iobject may be used to write to the standard input and read from the ;TI"(standard output of this subprocess.;T@o;
;	[	I">If the command following the pipe is a single minus sign ;TI"N(<code>"|-"</code>), Ruby forks, and this subprocess is connected to the ;TI"Nparent.  If the command is not <code>"-"</code>, the subprocess runs the ;TI"
command.;T@o;
;	[I"LWhen the subprocess is Ruby (opened via <code>"|-"</code>), the +open+ ;TI"Lcall returns +nil+.  If a block is associated with the open call, that ;TI"Gblock will run twice --- once in the parent and once in the child.;T@o;
;	[I"MThe block parameter will be an IO object in the parent and +nil+ in the ;TI"Mchild. The parent's +IO+ object will be connected to the child's $stdin ;TI"Mand $stdout.  The subprocess will be terminated at the end of the block.;T@S:RDoc::Markup::Heading:
leveli:	textI"
Examples;T@o;
;	[I"Reading from "testfile":;T@o:RDoc::Markup::Verbatim;	[I"open("testfile") do |f|
;TI"  print f.gets
;TI"	end
;T:@format0o;
;	[I"Produces:;T@o;;	[I"This is line one
;T;0o;
;	[I"+Open a subprocess and read its output:;T@o;;	[I"cmd = open("|date")
;TI"print cmd.gets
;TI"cmd.close
;T;0o;
;	[I"Produces:;T@o;;	[I""Wed Apr  9 08:56:31 CDT 2003
;T;0o;
;	[I"5Open a subprocess running the same Ruby program:;T@o;;	[I"f = open("|-", "w+")
;TI"if f.nil?
;TI"  puts "in Child"
;TI"  exit
;TI"
else
;TI"  puts "Got: #{f.gets}"
;TI"	end
;T;0o;
;	[I"Produces:;T@o;;	[I"Got: in Child
;T;0o;
;	[I">Open a subprocess using a block to receive the IO object:;T@o;;	[I"open "|-" do |f|
;TI"  if f then
;TI"    # parent process
;TI"    puts "Got: #{f.gets}"
;TI"  else
;TI"    # child process
;TI"    puts "in Child"
;TI"  end
;TI"	end
;T;0o;
;	[I"Produces:;T@o;;	[I"Got: in Child;T;0:
@fileI"	io.c;T:0@omit_headings_from_table_of_contents_below0I"|open(path [, mode [, perm]] [, opt])                -> io or nil
open(path [, mode [, perm]] [, opt]) {|io| block }  -> obj
;T0[I"(*args);T@}FI"Kernel;TcRDoc::NormalModule00