Class: SolrWrapper::Popen4Runner

Inherits:
Runner
  • Object
show all
Defined in:
lib/solr_wrapper/popen4_runner.rb

Overview

Runs a command using popen4 (typically for JRuby)

Instance Attribute Summary

Attributes inherited from Runner

#cmd, #config, #options

Instance Method Summary collapse

Methods inherited from Runner

#initialize, #silence_output?

Constructor Details

This class inherits a constructor from SolrWrapper::Runner

Instance Method Details

#run(stringio) ⇒ Object



4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
# File 'lib/solr_wrapper/popen4_runner.rb', line 4

def run(stringio)
  pid, input, output, error = IO.popen4(command)
  if config.verbose? && !silence_output?
    IO.copy_stream(output, $stderr)
    IO.copy_stream(error, $stderr)
  else
    IO.copy_stream(output, stringio)
    IO.copy_stream(error, stringio)
  end

  input.close
  output.close
  error.close
  exit_status = Process.waitpid2(pid).last
  stringio.rewind
  exit_status
end