Repository navigation
Console: keep the Linux console reader alive when stdin becomes non-blocking - #1277
Open
berkleblebiciii wants to merge 2 commits into
Open
berkleblebiciii wants to merge 2 commits into
berkleblebiciii wants to merge 2 commits into
Conversation
…locking If a plugin or component (one embedding node.js for example) puts fd 0 in non-blocking mode, the reader thread's `read()` fails with EAGAIN, `std::getline(std::wcin, ...)` sets failbit, and the thread exits permanently - the console then only echoes input and never runs commands again. Detect that case, restore the blocking mode on fd 0 and retry. Real EOF (stdin closed while blocking) still ends the thread as before. Fixes openmultiplayer#1268
Contributor
|
How its different to this one? In which ways it's better than the already suggested method? |
AmyrAhmady
force-pushed
the
fix/1268-console-nonblocking-stdin
branch
from
October 10, 2026 00:42
a130c03 to
c01565d
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
On Linux, the server console permanently stops executing commands after a plugin or component puts stdin (fd 0) into non-blocking mode - for example a component embedding node.js, where
node:process/ libuv switches stdin to non-blocking. The console still echoes keystrokes, but no command is ever executed and not evenUnknown command or variable:is printed. Windows is unaffected.Root cause
The console reader thread does:
With fd 0 in non-blocking mode the underlying
read()fails withEAGAIN,std::getlinesets failbit, and the thread treats it as EOF and exits permanently. The stream stays in the failed state, so nothing is ever read again.Fix
On the failure path, when the thread is still valid, check fd 0's status flags: if
O_NONBLOCKis set, restore blocking mode,clear()the stream state and retry. Real EOF (stdin closed while blocking) still ends the thread exactly as before, so shutdown behaviour is unchanged.Tested with a node.js-embedding component running:
Before: first console input printed
Unknown command or variable: foo, after that the console never responded again. After the fix the console keeps working.Fixes #1268