Class: Vx::Lib::Shell::Process

Inherits:
Object
  • Object
show all
Defined in:
lib/vx/lib/shell/process.rb

Instance Method Summary collapse

Instance Method Details

#exec(*args, &block) ⇒ Object



11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
# File 'lib/vx/lib/shell/process.rb', line 11

def exec(*args, &block)
  options        = args.last.is_a?(Hash) ? args.pop : {}
  command        = args.first

  select_timeout = options.delete(:pool_interval) || Shell.pool_interval
  timeout        = Shell::Timeout.new options.delete(:timeout)
  read_timeout   = Shell::ReadTimeout.new options.delete(:read_timeout)

  if command
    command = "/bin/bash -l -c #{Shellwords.escape command}"
  else
    command = "/bin/bash -l"
  end

  status = spawn_command_internal(command, options) do |r|
    read_loop r, timeout, read_timeout, select_timeout, &block
  end

  compute_exit_code command, status, timeout, read_timeout
end