From 4c2c698eea7fd286213e4557452bab74ae41b3fd Mon Sep 17 00:00:00 2001 From: Jaime Melis Date: Tue, 13 Sep 2016 16:58:32 +0200 Subject: [PATCH] F #4716: Fix bug in stderr handling (GenericCommand) --- src/mad/ruby/CommandManager.rb | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/mad/ruby/CommandManager.rb b/src/mad/ruby/CommandManager.rb index 6d6e9de75c..5c5fd181b6 100644 --- a/src/mad/ruby/CommandManager.rb +++ b/src/mad/ruby/CommandManager.rb @@ -43,6 +43,9 @@ require 'timeout' class GenericCommand + ERROR_OPEN = "ERROR MESSAGE --8<------" + ERROR_CLOSE = "ERROR MESSAGE ------>8--" + attr_reader :code, :stdout, :stderr, :command # Creates a command and runs it @@ -110,7 +113,10 @@ class GenericCommand process.call end rescue Timeout::Error - log("Timeout executing #{command}") + error_message = "Timeout executing #{command}" + log(error_message) + + @stderr = ERROR_OPEN + "\n" + error_message + "\n" + ERROR_CLOSE 3.times {|n| std[n].close if !std[n].closed? } @@ -125,7 +131,7 @@ class GenericCommand # Parses error message from +stderr+ output def get_error_message - tmp=@stderr.scan(/^ERROR MESSAGE --8<------\n(.*?)ERROR MESSAGE ------>8--$/m) + tmp=@stderr.scan(/^#{ERROR_OPEN}\n(.*?)#{ERROR_CLOSE}$/m) return "-" if !tmp[0] tmp[0].join(' ').strip end