Class: U3dCore::SafePopen

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

Overview

Executes commands using popen2 and takes care of error handling and more Note that the executed program might buffer the output as it isn’t run inside a pseudo terminal.

Class Method Summary collapse

Class Method Details

.spawn(command, &_block) ⇒ Object

Wraps the Open3.popen2e() call, wait until the process completes.



88
89
90
91
92
93
94
95
96
97
# File 'lib/u3d_core/command_runner.rb', line 88

def self.spawn(command, &_block)
  require 'open3'
  Open3.popen2e(command) do |r, w, p|
    yield w, r, p.value.pid # note the inversion

    r.close
    w.close
    p.value.exitstatus
  end
end