Class: Gerrit::Subprocess

Inherits:
Object
  • Object
show all
Defined in:
lib/gerrit/subprocess.rb

Overview

Manages execution of a child process, collecting the exit status and standard out/error output.

Defined Under Namespace

Classes: Result

Class Method Summary collapse

Class Method Details

.spawn(args) ⇒ Result

Spawns a new process using the given array of arguments (the first element is the command).

Parameters:

  • args (Array<String>)

Returns:



25
26
27
28
29
30
31
32
33
34
35
36
37
# File 'lib/gerrit/subprocess.rb', line 25

def spawn(args)
  process = ChildProcess.build(*args)

  out, err = assign_output_streams(process)

  process.start
  process.wait

  err.rewind
  out.rewind

  Result.new(process.exit_code, out.read, err.read)
end