Class: Secure::Runner
- Inherits:
-
Object
- Object
- Secure::Runner
- Defined in:
- lib/secure/runner.rb
Instance Method Summary collapse
-
#initialize(opts = {}, *args) ⇒ Runner
constructor
A new instance of Runner.
- #run ⇒ Object
Constructor Details
#initialize(opts = {}, *args) ⇒ Runner
Returns a new instance of Runner.
3 4 5 6 |
# File 'lib/secure/runner.rb', line 3 def initialize(opts = {}, *args) @opts = opts @args = args end |
Instance Method Details
#run ⇒ Object
8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 |
# File 'lib/secure/runner.rb', line 8 def run read_file, write_file = IO.pipe child = fork do begin ChildProcess.new(@opts, read_file, write_file).execute { yield *@args } ensure exit end end Process.wait(child) ParentProcess.new(read_file, write_file).execute ensure read_file.close unless read_file.closed? write_file.close unless write_file.closed? end |