popen2e(*cmd, &block)
Class Public methods
::popen2e is similer to ::popen3 except it merges the standard output stream and the standard error stream.
Block form:
1 2 3 4 5 | Open3.popen2e([env,] cmd... [, opts]) {|stdin, stdout_and_stderr, wait_thr| pid = wait_thr.pid # pid of the started process. ... exit_status = wait_thr.value # Process::Status object returned. } |
Non-block form:
1 2 3 4 | stdin, stdout_and_stderr, wait_thr = Open3.popen2e([env,] cmd... [, opts]) ... stdin.close # stdin and stdout_and_stderr should be closed explicitly in this form. stdout_and_stderr.close |
See Process.spawn for the optional hash arguments env and opts.
Example:
1 2 3 4 5 6 7 8 9 | # check gcc warnings source = "foo.c" Open3.popen2e( "gcc" , "-Wall" , source) {|i,oe,t| oe. each {|line| if /warning/ =~ line ... end } } |
Please login to continue.