Skip to contentSkip to conversation

utils.c: run_child redirect stderr to stdout

PATCH New Aníbal Limón 1 participant 2 messages Jan 30, 2019

lore
Share & tools
lore
#0 lore raw

PATCH 1/2 utils.c: run_child redirect stderr to stdout

To fix buffer ordering problems.

---
 utils.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
utils.c +2 -1
index 01ee415..0813e3c 100644
@@ -250,7 +250,8 @@ run_child(char *run_ptest, int fd_stdout, int fd_stderr)
 	argv[1] = NULL;
 
 	dup2(fd_stdout, STDOUT_FILENO);
-	dup2(fd_stderr, STDERR_FILENO);
+	// XXX: Redirect stderr to stdout to avoid buffer ordering problems.
+	dup2(fd_stdout, STDERR_FILENO);
 	execv(run_ptest, argv);
 
 	exit(1);
Signature · 1 line
2.20.1
#1 lore raw

PATCH 2/2 utils.c: Print DURATION after ERROR

If a process gets killed by timeout or OOM the output could end without '\n' so add 'DURATION: N\n' after '\nERROR: ptest-dir\n'.

---
 utils.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
utils.c +1 -1
index 0813e3c..504df0b 100644
@@ -382,12 +382,12 @@ run_ptests(struct ptest_list *head, const struct ptest_options opts,
 						opts.timeout, fds, fps, &timeouted);
 				entime = time(NULL);
 				duration = entime - sttime;
-				fprintf(fps[0], "DURATION: %d\n", duration);
 
 				if (status) {
 					fprintf(fps[0], "\nERROR: Exit status is %d\n", status);
 					rc += 1;
 				}
+				fprintf(fps[0], "DURATION: %d\n", duration);
 				if (timeouted)
 					fprintf(fps[0], "TIMEOUT: %s\n", ptest_dir);
 
Signature · 1 line
2.20.1