diff options
author | Ian Chard <ian@mysociety.org> | 2013-05-15 09:33:06 +0100 |
---|---|---|
committer | Ian Chard <ian@mysociety.org> | 2013-05-15 09:33:06 +0100 |
commit | 1071cade0f4bc928ec70e99ffe8624e7f6b52846 (patch) | |
tree | 4e3b864cc26f494b7071a0f5052e12f8b8e5371e /lib | |
parent | 2cfad24e21f954099ae84d782373d3bc6336db37 (diff) |
Add option to limit memory available to external commands
Diffstat (limited to 'lib')
-rw-r--r-- | lib/alaveteli_external_command.rb | 4 |
1 files changed, 4 insertions, 0 deletions
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 |