diff options
Diffstat (limited to 'meta/recipes-support/ptest-runner/ptest-runner/0001-utils-Ensure-stdout-stderr-are-flushed.patch')
| -rw-r--r-- | meta/recipes-support/ptest-runner/ptest-runner/0001-utils-Ensure-stdout-stderr-are-flushed.patch | 45 |
1 files changed, 45 insertions, 0 deletions
diff --git a/meta/recipes-support/ptest-runner/ptest-runner/0001-utils-Ensure-stdout-stderr-are-flushed.patch b/meta/recipes-support/ptest-runner/ptest-runner/0001-utils-Ensure-stdout-stderr-are-flushed.patch new file mode 100644 index 0000000000..c9a9dd7cf4 --- /dev/null +++ b/meta/recipes-support/ptest-runner/ptest-runner/0001-utils-Ensure-stdout-stderr-are-flushed.patch | |||
| @@ -0,0 +1,45 @@ | |||
| 1 | From 9b36993794c1de733c521b2477370c874c07b617 Mon Sep 17 00:00:00 2001 | ||
| 2 | From: Richard Purdie <richard.purdie@linuxfoundation.org> | ||
| 3 | Date: Thu, 4 Apr 2019 14:18:55 +0100 | ||
| 4 | Subject: [PATCH 1/3] utils: Ensure stdout/stderr are flushed | ||
| 5 | |||
| 6 | There is no guarantee that the data written with fwrite will be flushed to the | ||
| 7 | buffer. If stdout and stderr are the same thing, this could lead to interleaved | ||
| 8 | writes. The common case is stdout output so flush the output pipes when writing to | ||
| 9 | stderr. Also flush stdout before the function returns. | ||
| 10 | |||
| 11 | Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org> | ||
| 12 | Upstream-Status: Pending [code being tested] | ||
| 13 | --- | ||
| 14 | utils.c | 7 +++++-- | ||
| 15 | 1 file changed, 5 insertions(+), 2 deletions(-) | ||
| 16 | |||
| 17 | diff --git a/utils.c b/utils.c | ||
| 18 | index 504df0b..3ceb342 100644 | ||
| 19 | --- a/utils.c | ||
| 20 | +++ b/utils.c | ||
| 21 | @@ -295,8 +295,11 @@ wait_child(const char *ptest_dir, const char *run_ptest, pid_t pid, | ||
| 22 | } | ||
| 23 | |||
| 24 | if (pfds[1].revents != 0) { | ||
| 25 | - while ((n = read(fds[1], buf, WAIT_CHILD_BUF_MAX_SIZE)) > 0) | ||
| 26 | + while ((n = read(fds[1], buf, WAIT_CHILD_BUF_MAX_SIZE)) > 0) { | ||
| 27 | + fflush(fps[0]); | ||
| 28 | fwrite(buf, n, 1, fps[1]); | ||
| 29 | + fflush(fps[1]); | ||
| 30 | + } | ||
| 31 | } | ||
| 32 | |||
| 33 | clock_gettime(clock, &sentinel); | ||
| 34 | @@ -315,7 +318,7 @@ wait_child(const char *ptest_dir, const char *run_ptest, pid_t pid, | ||
| 35 | break; | ||
| 36 | } | ||
| 37 | |||
| 38 | - | ||
| 39 | + fflush(fps[0]); | ||
| 40 | return status; | ||
| 41 | } | ||
| 42 | |||
| 43 | -- | ||
| 44 | 2.17.1 | ||
| 45 | |||
