diff options
author | Karen Arutyunov <karen@codesynthesis.com> | 2016-07-12 17:24:00 +0300 |
---|---|---|
committer | Karen Arutyunov <karen@codesynthesis.com> | 2016-07-23 19:42:48 +0300 |
commit | 6c8e3f09c185d7fa4664ccd9e5c4f623a17b84cc (patch) | |
tree | 513f523dba31f275994d8152c02db82f3380c56e /butl/pager.cxx | |
parent | 09bedede7116961fbfb298a6a6cfa933af7af682 (diff) |
Extend fdstream
Diffstat (limited to 'butl/pager.cxx')
-rw-r--r-- | butl/pager.cxx | 22 |
1 files changed, 12 insertions, 10 deletions
diff --git a/butl/pager.cxx b/butl/pager.cxx index 0f29bb4..3d429f5 100644 --- a/butl/pager.cxx +++ b/butl/pager.cxx @@ -5,20 +5,20 @@ #include <butl/pager> #ifndef _WIN32 -# include <unistd.h> // close(), STDOUT_FILENO +# include <unistd.h> // STDOUT_FILENO # include <sys/ioctl.h> // ioctl() # include <chrono> # include <thread> // this_thread::sleep_for() #else # include <butl/win32-utility> - -# include <io.h> // _close() #endif #include <cstring> // strchr() #include <system_error> +#include <butl/fdstream> // fdclose() + using namespace std; namespace butl @@ -130,11 +130,8 @@ namespace butl bool r; if (p_.try_wait (r)) { -#ifndef _WIN32 - close (p_.out_fd); -#else - _close (p_.out_fd); -#endif + fdclose (p_.out_fd); + if (pager != nullptr) throw system_error (ECHILD, system_category ()); } @@ -162,7 +159,7 @@ namespace butl } bool pager:: - wait () + wait (bool ie) { // Teardown the indentation machinery. // @@ -172,8 +169,13 @@ namespace butl buf_ = nullptr; } + // Prevent ofdstream::close() from throwing in the ignore errors mode. + // + if (ie) + os_.exceptions (ofdstream::goodbit); + os_.close (); - return p_.wait (); + return p_.wait (ie); } pager::int_type pager:: |