File indexing completed on 2025-01-18 09:50:05
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010 #ifndef BOOST_PROCESS_DETAIL_POSIX_CLOSE_OUT_HPP
0011 #define BOOST_PROCESS_DETAIL_POSIX_CLOSE_OUT_HPP
0012
0013 #include <boost/process/detail/used_handles.hpp>
0014 #include <boost/process/detail/posix/handler.hpp>
0015 #include <array>
0016
0017 namespace boost { namespace process { namespace detail { namespace posix {
0018
0019 template<int p1, int p2>
0020 struct close_out : handler_base_ext
0021 {
0022 template <class Executor>
0023 inline void on_exec_setup(Executor &e) const;
0024
0025 std::array<int, 2> get_used_handles() {return {{p1 != -1 ? p1 : p2, p2 != -1 ? p2 : p1}};}
0026 };
0027
0028 template<>
0029 template<typename Executor>
0030 void close_out<1,-1>::on_exec_setup(Executor &e) const
0031 {
0032 if (::close(STDOUT_FILENO) == -1)
0033 e.set_error(::boost::process::detail::get_last_error(), "close() failed");
0034
0035 }
0036
0037 template<>
0038 template<typename Executor>
0039 void close_out<2,-1>::on_exec_setup(Executor &e) const
0040 {
0041 if (::close(STDERR_FILENO) == -1)
0042 e.set_error(::boost::process::detail::get_last_error(), "close() failed");
0043 }
0044
0045 template<>
0046 template<typename Executor>
0047 void close_out<1,2>::on_exec_setup(Executor &e) const
0048 {
0049 if (::close(STDOUT_FILENO) == -1)
0050 e.set_error(::boost::process::detail::get_last_error(), "close() failed");
0051
0052 if (::close(STDERR_FILENO) == -1)
0053 e.set_error(::boost::process::detail::get_last_error(), "close() failed");
0054 }
0055
0056 }}}}
0057
0058 #endif