diff options
-rw-r--r-- | lib/igt_core.c | 25 |
1 files changed, 17 insertions, 8 deletions
diff --git a/lib/igt_core.c b/lib/igt_core.c index 558a538d..8e7f0da8 100644 --- a/lib/igt_core.c +++ b/lib/igt_core.c @@ -1518,6 +1518,21 @@ static void fork_helper_exit_handler(int sig) assert(helper_process_count == 0); } +static pid_t __igt_fork_wrapper(void) +{ + pid_t ret; + + /* ensure any buffers are flushed before fork */ + fflush(stdout); + fflush(stderr); + + pthread_mutex_lock(&log_buffer_mutex); + ret = fork(); + pthread_mutex_unlock(&log_buffer_mutex); + + return ret; +} + bool __igt_fork_helper(struct igt_helper_process *proc) { pid_t pid; @@ -1540,10 +1555,7 @@ bool __igt_fork_helper(struct igt_helper_process *proc) tmp_count = exit_handler_count; exit_handler_count = 0; - /* ensure any buffers are flushed before fork */ - fflush(NULL); - - switch (pid = fork()) { + switch (pid = __igt_fork_wrapper()) { case -1: exit_handler_count = tmp_count; igt_assert(0); @@ -1642,10 +1654,7 @@ bool __igt_fork(void) igt_assert(test_children); } - /* ensure any buffers are flushed before fork */ - fflush(NULL); - - switch (test_children[num_test_children++] = fork()) { + switch (test_children[num_test_children++] = __igt_fork_wrapper()) { case -1: igt_assert(0); case 0: |