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

@@ -1,6 +1,6 @@
// Log writes on a thread of their own.
//
// A log line was written by the thread that logged it: to stderr and to the log file (main.c log_sink). A write can
// A log line was written by the thread that logged it: to the log file and to stderr (main.c log_sink). A write can
// stall: a console that scrolls, a pipe whose reader is busy, a virus scanner, a disk that flushes; hundreds of
// milliseconds at worst. The render thread logs too, and a frame it spends in such a write is a hitch with nothing
// else to show for it.