From 321d0c079230cbd447a8456db24ecd7eb2fd1be4 Mon Sep 17 00:00:00 2001 From: hannesweisbach Date: Tue, 29 Oct 2019 08:35:24 +0100 Subject: [PATCH] Fix output redirection of exec_prerun/_postrun MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit The previous version used the bashism "&>" to redirect stdout and stderr of the prerun/postrun commands to an output file. Since system() executes the command using "/bin/sh sh -c …". If /bin/sh is not bash, this wont work. Use the "posixly-correct" way of redirecting stdout to the output file and then redirect stderr to stdout. Signed-off-by: Hannes Weisbach --- backend.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/backend.c b/backend.c index fe868271..54273f8d 100644 --- a/backend.c +++ b/backend.c @@ -1469,12 +1469,12 @@ static bool keep_running(struct thread_data *td) static int exec_string(struct thread_options *o, const char *string, const char *mode) { - size_t newlen = strlen(string) + strlen(o->name) + strlen(mode) + 9 + 1; + size_t newlen = strlen(string) + strlen(o->name) + strlen(mode) + 13 + 1; int ret; char *str; str = malloc(newlen); - sprintf(str, "%s &> %s.%s.txt", string, o->name, mode); + sprintf(str, "%s > %s.%s.txt 2>&1", string, o->name, mode); log_info("%s : Saving output of %s in %s.%s.txt\n",o->name, mode, o->name, mode); ret = system(str); -- 2.25.1