Write the log file before stderr, and keep a blocked console from stopping the log and the exit.

A selection in the console window of a game started directly held back the write to stderr, and with it the log
file, the exit hook and the crash report. The log file now comes first, stderr goes past the C runtime's stream lock,
and the lines of an exit, a fatal error or a crash skip stderr while another thread is stuck in it. A game run turns
the console's QuickEdit mode off, and a closed console, Ctrl+C or Ctrl+Break ends the game the way a closed window
does, with the settings and saves written and the exit logged.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
chrg6
2026-11-13 05:53:29 -05:00
parent 175033d49a
commit e682934bd0
7 changed files with 124 additions and 11 deletions

View File

@@ -1884,6 +1884,21 @@ int plat_stderr_path(char *out, size_t cap) {
return 1;
}
int plat_stderr_write(const void *p, size_t n) {
for (const char *c = p; n;) {
ssize_t k = write(2, c, n);
if (k < 0 && errno == EINTR) continue;
if (k <= 0) return 0;
c += k, n -= (size_t)k;
}
return 1;
}
int plat_console_setup(void (*on_close)(const char *what)) { // a Windows console's settings only
(void)on_close;
return 0;
}
// ---- process
#ifdef NX2NAVI_PGO_GEN