Skip to contentSkip to conversation

utils: Ensure buffers are flushed after child exits

PATCH New Richard Purdie 1 participant 1 message Jun 18, 2023

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 utils: Ensure buffers are flushed after child exits

We currently wait for the child to exit but we don't flush the buffers. This can mean the output ends up out of sync and the END: line isn't at the end of the logs.

We've recently seen a lot of issues related to this on the autobuilder. Add in a flush call for all fds to ensure buffers are in sync. This does appear to improve warnings on the autobuilder now we started detecting the issue.

---
 README.md | 2 +-
 utils.c   | 3 +++
 2 files changed, 4 insertions(+), 1 deletion(-)
README.md +1 -1
index 85ef58a..e6f548e 100644
@@ -49,7 +49,7 @@ $ mtrace ./ptest-runner $MALLOC_TRACE
 ## Contributions
 
 For contribute please send a patch with subject prefix "[ptest-runner]" to 
[email protected].
[email protected].
 
 ## Links
 
utils.c +3 -0
index a67ac11..ec57fa4 100644
@@ -535,6 +535,9 @@ run_ptests(struct ptest_list *head, const struct ptest_options opts,
 				entime = time(NULL);
 				duration = entime - sttime;
 
+				/* Now the child has exited, ensure buffers are in sync before writing */
+				fflush(NULL);
+
 				if (status) {
 					fprintf(fp, "\nERROR: Exit status is %d\n", status);
 					rc += 1;
Signature · 1 line
2.39.2