Module: LXC::Extra
- Included in:
- Container
- Defined in:
- lib/lxc/extra.rb,
lib/lxc/extra/version.rb
Constant Summary collapse
- VERSION =
"0.0.2"
Instance Method Summary collapse
Instance Method Details
#execute(&block) ⇒ Object
7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 |
# File 'lib/lxc/extra.rb', line 7 def execute(&block) r,w = IO.pipe ret = attach(wait:true) do ENV.clear ENV['PATH'] = '/usr/bin:/bin:/usr/sbin:/sbin' ENV['TERM'] = 'xterm-256color' ENV['SHELL'] = '/bin/bash' r.close begin out = block.call w.write(Marshal.dump(out)) rescue Exception => e w.write(Marshal.dump(e)) end end w.close o = nil if r.ready? o = Marshal.load(r.read) end r.close raise o if o.is_a?(Exception) o end |