lib/mini_magick/shell.rb in mini_magick-4.11.0 vs lib/mini_magick/shell.rb in mini_magick-4.12.0
- old
+ new
@@ -12,22 +12,22 @@
def run(command, options = {})
stdout, stderr, status = execute(command, stdin: options[:stdin])
if status != 0 && options.fetch(:whiny, MiniMagick.whiny)
- fail MiniMagick::Error, "`#{command.join(" ")}` failed with error:\n#{stderr}"
+ fail MiniMagick::Error, "`#{command.join(" ")}` failed with status: #{status} and error:\n#{stderr}"
end
$stderr.print(stderr) unless options[:stderr] == false
[stdout, stderr, status]
end
def execute(command, options = {})
stdout, stderr, status =
log(command.join(" ")) do
- send("execute_#{MiniMagick.shell_api.gsub("-", "_")}", command, options)
+ send("execute_#{MiniMagick.shell_api.tr("-", "_")}", command, options)
end
[stdout, stderr, status.exitstatus]
rescue Errno::ENOENT, IOError
["", "executable not found: \"#{command.first}\"", 127]
@@ -48,12 +48,10 @@
in_w.write options[:stdin].to_s
rescue Errno::EPIPE
end
in_w.close
- begin
- Timeout.timeout(MiniMagick.timeout) { thread.join }
- rescue Timeout::Error
+ unless thread.join(MiniMagick.timeout)
Process.kill("TERM", thread.pid) rescue nil
Process.waitpid(thread.pid) rescue nil
raise Timeout::Error, "MiniMagick command timed out: #{command}"
end