Module: Proxy::OpenSCAP::Helpers
- Defined in:
- lib/smart_proxy_openscap/helpers.rb
Instance Method Summary collapse
Instance Method Details
#forked_response ⇒ Object
6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 |
# File 'lib/smart_proxy_openscap/helpers.rb', line 6 def forked_response r, w = IO.pipe if child_id = Process.fork w.close data = r.read r.close Process.wait(child_id) JSON.parse(data) else r.close begin body, code = yield w.write({ code: code, body: body }.to_json) rescue Exception => e w.write({ code: 500, body: e. }.to_json) end w.close Process.exit! end end |