Don't close the client's log file while a thread can still write it

On the MSVC path the input thread is never waited on, it blocks in a
console read with nothing to cancel it, so it can still be logging when
main closes the file named by -E.

- Flush the log there and let process exit close the stream
- The POSIX path joins its threads first, it still closes the file
pull/1171/head
John Safranek 2026-08-14 09:27:47 -07:00 committed by philljj
parent 50ce6135f7
commit 62c0e2efa5
1 changed files with 8 additions and 0 deletions

View File

@ -1422,8 +1422,16 @@ int main(int argc, char** argv)
/* Close the log last, wolfSSH_Cleanup() still logs and the callback
* cannot be uninstalled. */
if (logFileStream != NULL) {
#ifdef _MSC_VER
/* The terminal session's input thread is left running, it blocks in
* a console read with nothing to cancel it. Flush the log and let
* process exit close it, rather than close the stream out from under
* a write that thread is making. */
WFFLUSH(logFileStream);
#else
WFCLOSE(NULL, logFileStream);
logFileStream = NULL;
#endif
}
config_cleanup(&clientConfig);