D7net
Home
Console
Upload
information
Create File
Create Folder
About
Tools
:
/
opt
/
alt
/
ruby34
/
share
/
ri
/
system
/
Open3
/
Filename :
pipeline_r-c.ri
back
Copy
U:RDoc::AnyMethod[iI"pipeline_r:ETI"Open3::pipeline_r;TT:publico:RDoc::Markup::Document:@parts[#o:RDoc::Markup::Paragraph; [I"Basically a wrapper for ;TI"-{Process.spawn}[rdoc-ref:Process.spawn] ;TI" that:;To:RDoc::Markup::BlankLine o:RDoc::Markup::List: @type:BULLET:@items[o:RDoc::Markup::ListItem:@label0; [o; ; [I":Creates a child process for each of the given +cmds+ ;TI"by calling Process.spawn.;To;;0; [o; ; [I"JPipes the +stdout+ from each child to the +stdin+ of the next child, ;TI"6or, for the last child, to the caller's +stdout+.;T@o; ; [I";The method does not wait for child processes to exit, ;TI"so the caller must do so.;T@o; ; [I"?With no block given, returns a 2-element array containing:;T@o;; ;;[o;;0; [o; ; [I"3The +stdout+ stream of the last child process.;To;;0; [o; ; [I"AAn array of the wait threads for all of the child processes.;T@o; ; [I" Example:;T@o:RDoc::Markup::Verbatim; [I"Blast_stdout, wait_threads = Open3.pipeline_r('ls', 'grep R') ;TI"r# => [#<IO:fd 5>, [#<Process::Waiter:0x000055e8de2f9898 dead>, #<Process::Waiter:0x000055e8de2f94b0 sleep>]] ;TI"puts last_stdout.read ;TI"(wait_threads.each do |wait_thread| ;TI" wait_thread.join ;TI" end ;T:@format0o; ; [I"Output:;T@o;; [I"Rakefile ;TI"README.md ;T;0o; ; [I"BWith a block given, calls the block with the +stdout+ stream ;TI" of the last child process, ;TI"(and an array of the wait processes:;T@o;; [I"EOpen3.pipeline_r('ls', 'grep R') do |last_stdout, wait_threads| ;TI" puts last_stdout.read ;TI"* wait_threads.each do |wait_thread| ;TI" wait_thread.join ;TI" end ;TI" end ;T;0o; ; [I"Output:;T@o;; [I"Rakefile ;TI"README.md ;T;0o; ; [I"LLike Process.spawn, this method has potential security vulnerabilities ;TI"%if called with untrusted input; ;TI"Psee {Command Injection}[rdoc-ref:command_injection.rdoc@Command+Injection].;T@o; ; [I"HIf the first argument is a hash, it becomes leading argument +env+ ;TI"$in each call to Process.spawn; ;TI"Isee {Execution Environment}[rdoc-ref:Process@Execution+Environment].;T@o; ; [I"LIf the last argument is a hash, it becomes trailing argument +options+ ;TI"$in each call to Process.spawn; ;TI"Asee {Execution Options}[rdoc-ref:Process@Execution+Options].;T@o; ; [I"1Each remaining argument in +cmds+ is one of:;T@o;; ;;[o;;0; [o; ; [I"GA +command_line+: a string that begins with a shell reserved word ;TI"Aor special built-in, or contains one or more metacharacters.;To;;0; [o; ; [I"BAn +exe_path+: the string path to an executable to be called.;To;;0; [o; ; [I"<An array containing a +command_line+ or an +exe_path+, ;TI">along with zero or more string arguments for the command.;T@o; ; [I"aSee {Argument command_line or exe_path}[rdoc-ref:Process@Argument+command_line+or+exe_path].;T: @fileI"lib/open3.rb;T:0@omit_headings_from_table_of_contents_below0I"ROpen3.pipeline_r([env, ] *cmds, options = {}) -> [last_stdout, wait_threads] ;T0[ I"(*cmds, &block);T@{FI" Open3;TcRDoc::NormalModule00