Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 8 additions & 2 deletions lib/secure/runner.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ class Runner
def initialize(opts = {}, *args)
@opts = opts
@args = args
@timeout = opts[:timeout]
end

def run
Expand All @@ -15,9 +16,14 @@ def run
exit
end
end

Process.wait(child)
Timeout.timeout @timeout do
Process.wait(child)
end
ParentProcess.new(read_file, write_file).execute
rescue Timeout::Error
Process.kill(9, child)
Process.wait(child)
raise
ensure
read_file.close unless read_file.closed?
write_file.close unless write_file.closed?
Expand Down