Skip to content

Fix stderr being buffered on windows#150

Merged
MrPowerGamerBR merged 1 commit into
ButterscotchRunner:mainfrom
Un1q32:unbuffered-stderr
May 23, 2026
Merged

Fix stderr being buffered on windows#150
MrPowerGamerBR merged 1 commit into
ButterscotchRunner:mainfrom
Un1q32:unbuffered-stderr

Conversation

@Un1q32
Copy link
Copy Markdown
Contributor

@Un1q32 Un1q32 commented May 21, 2026

On Windows, SDL 1.2 may call freopen() on stdout and stderr to make them output to files instead of a terminal. In these cases, stderr might be buffered instead of unbuffered like it should, which means output might be lost if abort() is called. This setbuf call ensures the stream is always unbuffered, and is effectively a nop if stderr is already unbuffered.

@iProgramMC
Copy link
Copy Markdown
Contributor

can't we, instead, prevent SDL 1.2 from taking over stderr/stdout somehow?

@Un1q32
Copy link
Copy Markdown
Contributor Author

Un1q32 commented May 22, 2026

can't we, instead, prevent SDL 1.2 from taking over stderr/stdout somehow?

Doing this requires passing --disable-stdio-redirect at configure time for SDL, which might not be possible if someone is using some vendored library. Also, someone might actually want to redirect stdio for whatever reason.

@MrPowerGamerBR MrPowerGamerBR merged commit 338bc09 into ButterscotchRunner:main May 23, 2026
11 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants