From 1071cade0f4bc928ec70e99ffe8624e7f6b52846 Mon Sep 17 00:00:00 2001 From: Ian Chard Date: Wed, 15 May 2013 09:33:06 +0100 Subject: Add option to limit memory available to external commands --- lib/alaveteli_external_command.rb | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'lib/alaveteli_external_command.rb') diff --git a/lib/alaveteli_external_command.rb b/lib/alaveteli_external_command.rb index 24b4b1aa8..5e9a7ee83 100644 --- a/lib/alaveteli_external_command.rb +++ b/lib/alaveteli_external_command.rb @@ -8,6 +8,7 @@ module AlaveteliExternalCommand # :stdin_string - stdin string to pass to the process # :binary_output - boolean flag for treating the output as binary or text (only significant # ruby 1.9 and above) + # :memory_limit - maximum amount of memory (in bytes) available to the process def run(program_name, *args) # Run an external program, and return its output. # Standard error is suppressed unless the program @@ -38,6 +39,9 @@ module AlaveteliExternalCommand if opts.has_key? :binary_output xc.binary_mode = opts[:binary_output] end + if opts.has_key? :memory_limit + xc.memory_limit = opts[:memory_limit] + end xc.run(opts[:stdin_string] || "", opts[:env] || {}) if xc.status != 0 -- cgit v1.2.3