Sha256: d4a61fb593a29dad396abee6ae66f74149d5d6353128649602dae2f848a7e486
Contents?: true
Size: 1.37 KB
Versions: 15
Compression:
Stored size: 1.37 KB
Contents
# frozen_string_literal: true module ScriptCore class ServiceProcess attr_reader(:path, :spawner, :instruction_quota, :instruction_quota_start, :memory_quota, :environment_variables) def initialize(path, spawner, instruction_quota, instruction_quota_start, memory_quota, environment_variables = {}) @path = path @spawner = spawner @instruction_quota = instruction_quota @instruction_quota_start = instruction_quota_start @memory_quota = memory_quota @environment_variables = environment_variables end def open in_reader, in_writer = IO.pipe out_reader, out_writer = IO.pipe pid = spawner.spawn( environment_variables, path, "-i", instruction_quota.to_s, "-C", instruction_quota_start.to_s, "-m", memory_quota.to_s, in: in_reader, out: out_writer, unsetenv_others: true ) in_reader.close out_writer.close in_writer.binmode out_reader.binmode begin yield ScriptCore::ServiceChannel.new(in_writer, out_reader) ensure code = spawner.wait(pid, Process::WNOHANG) || begin begin spawner.kill(9, pid) spawner.wait(pid) rescue Errno::ESRCH -1 end end out_reader.close in_writer.close end code end end end
Version data entries
15 entries across 15 versions & 1 rubygems