Skip to content

Commit

Permalink
[sclang][win] read stdin sync before starting async service
Browse files Browse the repository at this point in the history
this fixes supercollider#4214 - the initial read of stdin was being lost while starting the async reading service
  • Loading branch information
jrsurge authored and dyfer committed Feb 14, 2020
1 parent c838269 commit a9de9eb
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions lang/LangSource/SC_TerminalClient.cpp
Expand Up @@ -590,6 +590,17 @@ void SC_TerminalClient::inputThreadFn() {
readlineInit();
#endif

#ifdef _WIN32
// make sure there's nothing on stdin before we launch the service
// this fixes #4214
DWORD bytesRead = 0;
auto success = ReadFile(GetStdHandle(STD_INPUT_HANDLE), inputBuffer.data(), inputBuffer.size(), &bytesRead, NULL);

if (success) {
pushCmdLine(inputBuffer.data(), bytesRead);
}
#endif

startInputRead();

boost::asio::io_service::work work(mInputService);
Expand Down

0 comments on commit a9de9eb

Please sign in to comment.