mirror of
https://github.com/sockspls/badfish
synced 2025-04-30 00:33:09 +00:00
Set unbuffered I/O also for C standard library
In input_available() we use function select(), so we have to set as unbuffered also C library I/O functions otherwise we can miss some input. For instance in case GUI sends "go infinite\nstop\n" we parse the "go infinite" but then input_available() under Linux is unable to detect that we still have "stop" to be processed. This is because "select" uses file descriptors instead of file pointers. So it cannot know about the buffer associated to a file pointer. This patch, by BB+, should fix the problem. No functional change. Signed-off-by: Marco Costalba <mcostalba@gmail.com>
This commit is contained in:
parent
611a29f767
commit
d4b92ae9a0
1 changed files with 4 additions and 1 deletions
|
@ -25,6 +25,7 @@
|
|||
//// Includes
|
||||
////
|
||||
|
||||
#include <cstdio>
|
||||
#include <iostream>
|
||||
#include <string>
|
||||
|
||||
|
@ -54,7 +55,9 @@ extern void benchmark(int argc, char* argv[]);
|
|||
|
||||
int main(int argc, char* argv[]) {
|
||||
|
||||
// Disable IO buffering
|
||||
// Disable IO buffering for C and C++ standard libraries
|
||||
setvbuf(stdin, NULL, _IONBF, 0);
|
||||
setvbuf(stdout, NULL, _IONBF, 0);
|
||||
cout.rdbuf()->pubsetbuf(NULL, 0);
|
||||
cin.rdbuf()->pubsetbuf(NULL, 0);
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue