Fix output redirection of exec_prerun/_postrun
authorhannesweisbach <hannesweisbach@users.noreply.github.com>
Tue, 29 Oct 2019 07:35:24 +0000 (08:35 +0100)
committerGitHub <noreply@github.com>
Tue, 29 Oct 2019 07:35:24 +0000 (08:35 +0100)
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 <hannes.weisbach@gmail.com>
backend.c

index fe868271a6cd90e755743965bdaf0936826272c1..54273f8ddd5c04fc43b8622fba1e6979958bad26 100644 (file)
--- 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);