Class: Command

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

Class Method Summary collapse

Class Method Details

.execute(command) ⇒ Object

TODO: Move to own gem…



3
4
5
6
7
8
9
10
11
12
13
14
# File 'lib/command.rb', line 3

def self.execute(command)
  pid = 0
  exit_status = 0

  # Open3.popen3([env,] cmd... [, opts])
  Open3.popen3(command) do |stdin, stdout, stderr, wait_thr|
    pid = wait_thr.pid # pid of the started process.
    exit_status = wait_thr.value # Process::Status object returned.
  end

  exit_status
end