bin: workaround flushing issues
* bin/common_cout.cc (check_cout): Force a flush of cout if more than 20ms has elapsed since the last explicit flush. * bin/common_setup.cc (setup): Untie cin and cout if the input is not a TTY, so that cout is flush less often. * NEWS: Mention the change.
This commit is contained in:
parent
0678d1a662
commit
0c9c4be4ae
3 changed files with 44 additions and 6 deletions
|
|
@ -22,6 +22,7 @@
|
|||
|
||||
#include "argp.h"
|
||||
#include <cstdlib>
|
||||
#include <unistd.h>
|
||||
#include <iostream>
|
||||
#include <signal.h>
|
||||
#include <sys/wait.h>
|
||||
|
|
@ -83,6 +84,11 @@ setup(char** argv)
|
|||
argp_err_exit_status = 2;
|
||||
|
||||
std::ios_base::sync_with_stdio(false);
|
||||
// Do not flush std::cout every time we read from std::cin, unless
|
||||
// we are reading from a terminal. Note that we do flush regularly
|
||||
// in check_cout().
|
||||
if (!isatty(STDIN_FILENO))
|
||||
std::cin.tie(nullptr);
|
||||
|
||||
setup_default_output_format();
|
||||
setup_sig_handler();
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue