File indexing completed on 2025-01-18 09:50:06
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010 #ifndef BOOST_PROCESS_DETAIL_POSIX_NULL_IN_HPP
0011 #define BOOST_PROCESS_DETAIL_POSIX_NULL_IN_HPP
0012
0013 #include <boost/process/pipe.hpp>
0014 #include <boost/process/detail/posix/handler.hpp>
0015 #include <boost/process/detail/posix/file_descriptor.hpp>
0016 #include <unistd.h>
0017 #include <boost/process/detail/used_handles.hpp>
0018 #include <array>
0019
0020 namespace boost { namespace process { namespace detail { namespace posix {
0021
0022 struct null_in : handler_base_ext, ::boost::process::detail::uses_handles
0023 {
0024 file_descriptor source{"/dev/null", file_descriptor::read};
0025
0026 std::array<int, 2> get_used_handles()
0027 {
0028 return {{STDIN_FILENO, source.handle()}};
0029 }
0030
0031
0032 public:
0033 template <class Executor>
0034 void on_exec_setup(Executor &e) const
0035 {
0036 if (::dup2(source.handle(), STDIN_FILENO) == -1)
0037 e.set_error(::boost::process::detail::get_last_error(), "dup2() failed");
0038 }
0039 };
0040
0041 }}}}
0042
0043 #endif