From 46a7ae80695496859766ccb81fdd8ed409384ccc Mon Sep 17 00:00:00 2001
From: Jason Hiser <jdhiser@gmail.com>
Date: Fri, 30 Nov 2018 22:27:04 +0000
Subject: [PATCH] fixed --no-redirect option to use stdout instead of
 thanos.log

Former-commit-id: 4de52f8a60f794f63b196e231479365f53eb975a
---
 tools/thanos/thanos.cpp | 9 +++++++--
 1 file changed, 7 insertions(+), 2 deletions(-)

diff --git a/tools/thanos/thanos.cpp b/tools/thanos/thanos.cpp
index 5fd23d58c..fc2e7cabc 100644
--- a/tools/thanos/thanos.cpp
+++ b/tools/thanos/thanos.cpp
@@ -273,6 +273,11 @@ int ThanosPlugin_t::runPlugin()
 			dup2(fileno(logfile), STDOUT_FILENO);
 			dup2(fileno(logfile), STDERR_FILENO);
 		}
+		else
+		{
+			dup2(new_stdout_fd, STDOUT_FILENO);
+			dup2(new_stderr_fd, STDERR_FILENO);
+		}
 	}
 	
 
@@ -296,8 +301,8 @@ int ThanosPlugin_t::runPlugin()
         cout<< "#ATTRIBUTE step_exitcode="<<dec<<step_result<<endl;
 
 
-	dup2(new_stdout_fd, STDOUT_FILENO);
-	dup2(new_stderr_fd, STDERR_FILENO);
+	dup2(thanos_log_fd, STDOUT_FILENO);
+	dup2(thanos_log_fd, STDERR_FILENO);
 	if(logfile)
 		fclose(logfile);
 
-- 
GitLab