diff options
Diffstat (limited to 'libbuild2')
-rw-r--r-- | libbuild2/utility.cxx | 18 | ||||
-rw-r--r-- | libbuild2/utility.hxx | 2 |
2 files changed, 20 insertions, 0 deletions
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. |