Class: Backsum::LoggablePosixRunner
- Inherits:
-
Object
- Object
- Backsum::LoggablePosixRunner
- Defined in:
- lib/backsum/shell.rb
Instance Method Summary collapse
Instance Method Details
#call(command, env = {}) ⇒ Object
19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 |
# File 'lib/backsum/shell.rb', line 19 def call(command, env = {}) input, output = IO.pipe pid = spawn(env, command, :out => output) output.close result = "" while line = input.readline Backsum.logger.debug(line.chomp) result << line end rescue EOFError waitpid(pid) input.close result end |
#spawn(*args) ⇒ Object
35 36 37 |
# File 'lib/backsum/shell.rb', line 35 def spawn(*args) ::POSIX::Spawn.spawn(*args) end |
#waitpid(pid) ⇒ Object
39 40 41 |
# File 'lib/backsum/shell.rb', line 39 def waitpid(pid) ::Process.waitpid(pid) end |