lib/overcommit/subprocess.rb
# Spawns a new process using the given array of arguments (the first
# element is the command).
#
# @param args [Array<String>]
# @param options [Hash]
# @option options [String] input string to pass via standard input stream
# @return [Result]
Spawns a new process using the given array of arguments (the first
element is the command).
Spawns a new process using the given array of arguments ( the first element is the command ) .
def spawn(args, options = {})
        args = win32_prepare_args(args) if OS.windows?
        process = ChildProcess.build(*args)
        out, err = assign_output_streams(process)
        process.duplex = true if options[:input] 
        process.start
        if options[:input]
          begin
            process.io.stdin.puts(options[:input])
          rescue StandardError 
          ensure
            process.io.stdin.close
          end
        end
        process.wait
        err.rewind
        out.rewind
        Result.new(process.exit_code, out.read, err.read)
      end
def spawn ( args , options = { } ) args = win32_prepare_args ( args ) if OS . windows? process = ChildProcess . build ( * args ) out , err = assign_output_streams ( process ) process . duplex = true if options [ :input ] process . start if options [ :input ] begin process . io . stdin . puts ( options [ :input ] ) rescue StandardError ensure process . io . stdin . close end end process . wait err . rewind out . rewind Result . new ( process . exit_code , out . read , err . read ) end
Spawns a new process using the given array of arguments (the first
element is the command).
Spawns a new process using the given array of arguments ( the first element is the command ) .
# Make stdin available if needed # rubocop:disable Lint/HandleExceptions # Silently ignore if the standard input stream of the spawned # process is closed before we get a chance to write to it. This # happens on JRuby a lot.
None
Result
args
<not_specific>
options
input string to pass via standard input stream
input string to pass via standard input stream
<not_specific>
None