Class: Methadone::ExecutionStrategy::Open_4

Inherits:
MRI
  • Object
show all
Defined in:
lib/methadone/execution_strategy/open_4.rb

Overview

Methadone Internal - treat as private

ExecutionStrategy for non-modern Rubies that must rely on Open4 to get access to the standard output AND error.

Direct Known Subclasses

RBXOpen_4

Instance Method Summary collapse

Methods inherited from MRI

#exception_meaning_command_not_found

Methods inherited from Base

#exception_meaning_command_not_found

Instance Method Details

#run_command(command) ⇒ Object


8
9
10
11
12
13
14
15
16
17
18
19
# File 'lib/methadone/execution_strategy/open_4.rb', line 8

def run_command(command)
  pid, stdin_io, stdout_io, stderr_io =
    case command
    when String then Open4::popen4(command)
    else Open4::popen4(*command)
    end
  stdin_io.close
  stdout = stdout_io.read
  stderr = stderr_io.read
  _ , status = Process::waitpid2(pid)
  [stdout.chomp,stderr.chomp,status]
end