aboutsummaryrefslogtreecommitdiffstats
path: root/lib/alaveteli_external_command.rb
diff options
context:
space:
mode:
authorLouise Crow <louise.crow@gmail.com>2015-01-15 14:27:07 +0000
committerLouise Crow <louise.crow@gmail.com>2015-03-23 18:24:44 +0000
commitfb84ca9d3887325bb0e70fcde6a161f2b8a763ed (patch)
treef5293964b258c296718a11dedb526da820d6b104 /lib/alaveteli_external_command.rb
parenta80695e7194666c35a6ef419b3a1958c55f62d1c (diff)
Give a forced timeout its own error message.
Clarify grouping of command and arguments with quotes.
Diffstat (limited to 'lib/alaveteli_external_command.rb')
-rw-r--r--lib/alaveteli_external_command.rb13
1 files changed, 11 insertions, 2 deletions
diff --git a/lib/alaveteli_external_command.rb b/lib/alaveteli_external_command.rb
index 5f8214900..fc8e31368 100644
--- a/lib/alaveteli_external_command.rb
+++ b/lib/alaveteli_external_command.rb
@@ -36,21 +36,30 @@ module AlaveteliExternalCommand
if opts.has_key? :memory_limit
xc.memory_limit = opts[:memory_limit]
end
+
+
xc.run(opts[:stdin_string] || "", opts[:env] || {})
if !xc.exited
# Crash or timeout
- $stderr.puts("#{program_name} #{args.join(' ')}:exited abnormally")
+ if xc.timed_out
+ $stderr.puts(%Q[Command "#{program_name} #{args.join(' ')}" timed out at #{opts[:timeout]}s])
+ else
+ $stderr.puts(%Q[Command ""#{program_name} #{args.join(' ')}" exited abnormally])
+ end
+ $stderr.print(xc.err)
return nil
+
elsif xc.status != 0
# Error
- $stderr.puts("Error from #{program_name} #{args.join(' ')}:")
+ $stderr.puts(%Q[Error from command "#{program_name} #{args.join(' ')}":])
$stderr.print(xc.err)
return nil
else
if opts.has_key? :append_to
opts[:append_to] << "\n\n"
else
+
return xc.out
end
end