Class: AgentJail::Child
- Inherits:
-
Object
- Object
- AgentJail::Child
- Defined in:
- lib/agent_jail/child.rb
Overview
Runs inside the forked child process. Applies restrictions then executes the block, writing the result to the pipe.
Instance Method Summary collapse
-
#initialize(write:, cpu_timeout:, memory_mb:, fs_allow:, fs_read_allow:, block:) ⇒ Child
constructor
A new instance of Child.
- #run ⇒ Object
Constructor Details
#initialize(write:, cpu_timeout:, memory_mb:, fs_allow:, fs_read_allow:, block:) ⇒ Child
Returns a new instance of Child.
7 8 9 10 11 12 13 14 |
# File 'lib/agent_jail/child.rb', line 7 def initialize(write:, cpu_timeout:, memory_mb:, fs_allow:, fs_read_allow:, block:) @write = write @cpu_timeout = cpu_timeout @memory_mb = memory_mb @fs_allow = fs_allow @fs_read_allow = fs_read_allow @block = block end |
Instance Method Details
#run ⇒ Object
16 17 18 19 20 21 22 23 24 25 26 27 |
# File 'lib/agent_jail/child.rb', line 16 def run apply_restrictions begin result = @block.call Pipe.write_result(@write, result) rescue Exception => e Pipe.write_error(@write, e) ensure @write.close end end |