diff --git a/lib/diagnostics.cpp b/lib/diagnostics.cpp index ec3704abce..63ea1d7a07 100644 --- a/lib/diagnostics.cpp +++ b/lib/diagnostics.cpp @@ -666,8 +666,8 @@ int diagnostics_cycle_logs() { boinc_copy(stderr_log, stderr_archive); stderr_file_size = 0; stderr_file = freopen(stderr_log, "w", stderr); - setbuf(stderr_file, 0); if (NULL == stderr_file) return ERR_FOPEN; + setbuf(stderr_file, 0); } } @@ -679,6 +679,7 @@ int diagnostics_cycle_logs() { boinc_copy(stdout_log, stdout_archive); stdout_file = freopen(stdout_log, "w", stdout); if (NULL == stdout_file) return ERR_FOPEN; + setvbuf(stdout_file, NULL, _IOLBF, BUFSIZ); } } return BOINC_SUCCESS;