diff options
-rw-r--r-- | b/b.cxx | 20 | ||||
-rw-r--r-- | libbuild2/utility.cxx | 18 | ||||
-rw-r--r-- | libbuild2/utility.hxx | 2 |
3 files changed, 21 insertions, 19 deletions
@@ -7,7 +7,7 @@ #include <exception> // terminate(), set_terminate(), terminate_handler #include <libbutl/pager.hxx> -#include <libbutl/fdstream.hxx> // stderr_fd(), fdterm(), std*_fdmode() +#include <libbutl/fdstream.hxx> // stderr_fd(), fdterm() #include <libbutl/backtrace.hxx> // backtrace() #ifndef BUILD2_BOOTSTRAP @@ -259,24 +259,6 @@ main (int argc, char* argv[]) try { - // Note that the standard stream descriptors can potentially be in the - // non-blocking mode, which the C++ streams are not suited for and which - // are not fully supported by butl::iofdstreams. Using such descriptors - // may lead to various weird failures (see GH issue #417 for the - // reproducer). Thus, we just turn such descriptors into the blocking mode - // at the beginning of the program execution. - // - try - { - stdin_fdmode (fdstream_mode::blocking); - stdout_fdmode (fdstream_mode::blocking); - stderr_fdmode (fdstream_mode::blocking); - } - catch (const io_error& e) - { - fail << "unable to turn standard streams into blocking mode: " << e; - } - init_process (); // Parse the command line. diff --git a/libbuild2/utility.cxx b/libbuild2/utility.cxx index 83947b2..573ded9 100644 --- a/libbuild2/utility.cxx +++ b/libbuild2/utility.cxx @@ -880,6 +880,24 @@ namespace build2 void init_process () { + // Note that the standard stream descriptors can potentially be in the + // non-blocking mode, which the C++ streams are not suited for and which + // are not fully supported by butl::iofdstreams. Using such descriptors + // may lead to various weird failures (see GH issue #417 for the + // reproducer). Thus, we just turn such descriptors into the blocking mode + // at the beginning of the program execution. + // + try + { + stdin_fdmode (fdstream_mode::blocking); + stdout_fdmode (fdstream_mode::blocking); + stderr_fdmode (fdstream_mode::blocking); + } + catch (const io_error& e) + { + fail << "unable to turn standard streams into blocking mode: " << e; + } + // This is a little hack to make out baseutils for Windows work when // called with absolute path. In a nutshell, MSYS2's exec*p() doesn't // search in the parent's executable directory, only in PATH. And since we diff --git a/libbuild2/utility.hxx b/libbuild2/utility.hxx index 99d6806..70d7452 100644 --- a/libbuild2/utility.hxx +++ b/libbuild2/utility.hxx @@ -115,6 +115,8 @@ namespace build2 // called once early in main(). In particular, besides other things, this // functions does the following: // + // - Turn standard streams into blocking mode. + // // - Sets PATH to include baseutils /bin on Windows. // // - Ignores SIGPIPE. |