D7net
Home
Console
Upload
information
Create File
Create Folder
About
Tools
:
/
proc
/
self
/
root
/
opt
/
alt
/
ruby34
/
share
/
ri
/
system
/
PTY
/
Filename :
spawn-c.ri
back
Copy
U:RDoc::AnyMethod[iI" spawn:ETI"PTY::spawn;TT:publico:RDoc::Markup::Document:@parts[o:RDoc::Markup::Paragraph; [I"QSpawns the specified command on a newly allocated pty. You can also use the ;TI"alias ::getpty.;To:RDoc::Markup::BlankLine o; ; [I"IThe command's controlling tty is set to the slave device of the pty ;TI"Kand its standard input/output/error is redirected to the slave device.;T@o; ; [I"a+env+ is an optional hash that provides additional environment variables to the spawned pty.;T@o:RDoc::Markup::Verbatim; [I"# sets FOO to "bar" ;TI"APTY.spawn({"FOO"=>"bar"}, "printenv", "FOO") do |r, w, pid| ;TI" p r.read #=> "bar\r\n" ;TI"ensure ;TI"+ r.close; w.close; Process.wait(pid) ;TI" end ;TI"# unsets FOO ;TI"?PTY.spawn({"FOO"=>nil}, "printenv", "FOO") do |r, w, pid| ;TI" p r.read #=> "" ;TI"ensure ;TI"+ r.close; w.close; Process.wait(pid) ;TI" end ;T:@format0o; ; [I"P+command+ and +command_line+ are the full commands to run, given a String. ;TI">Any additional +arguments+ will be passed to the command.;T@S:RDoc::Markup::Heading: leveli: textI"Return values;T@o; ; [I"@In the non-block form this returns an array of size three, ;TI"<tt>[r, w, pid]</tt>.;T@o; ; [I"FIn the block form these same values will be yielded to the block:;T@o:RDoc::Markup::List: @type: NOTE:@items[o:RDoc::Markup::ListItem:@label[I"+r+;T; [o; ; [I"/A readable IO that contains the command's ;TI"'standard output and standard error;To;;[I"+w+;T; [o; ; [I"7A writable IO that is the command's standard input;To;;[I" +pid+;T; [o; ; [I",The process identifier for the command.;T@S;;i;I" Clean up;T@o; ; [I"IThis method does not clean up like closing IOs or waiting for child ;TI"Gprocess, except that the process is detached in the block form to ;TI"Hprevent it from becoming a zombie (see Process.detach). Any other ;TI"Icleanup is the responsibility of the caller. If waiting for +pid+, ;TI"Hbe sure to close both +r+ and +w+ before doing so; doing it in the ;TI"3reverse order may cause deadlock on some OSes.;T: @fileI"ext/pty/pty.c;T:0@omit_headings_from_table_of_contents_below0I"�PTY.spawn([env,] command_line) { |r, w, pid| ... } PTY.spawn([env,] command_line) => [r, w, pid] PTY.spawn([env,] command, arguments, ...) { |r, w, pid| ... } PTY.spawn([env,] command, arguments, ...) => [r, w, pid] ;T0[[I"getpty;T@ I"(*args);T@TFI"PTY;TcRDoc::NormalClass00