Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 09:50:08

0001 // Copyright (c) 2006, 2007 Julio M. Merino Vidal
0002 // Copyright (c) 2008 Ilya Sokolov, Boris Schaeling
0003 // Copyright (c) 2009 Boris Schaeling
0004 // Copyright (c) 2010 Felipe Tanus, Boris Schaeling
0005 // Copyright (c) 2011, 2012 Jeff Flinn, Boris Schaeling
0006 //
0007 // Distributed under the Boost Software License, Version 1.0. (See accompanying
0008 // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
0009 
0010 #ifndef BOOST_PROCESS_WINDOWS_INITIALIZERS_NULL_OUT_HPP
0011 #define BOOST_PROCESS_WINDOWS_INITIALIZERS_NULL_OUT_HPP
0012 
0013 #include <boost/winapi/process.hpp>
0014 #include <boost/winapi/handles.hpp>
0015 #include <boost/winapi/handle_info.hpp>
0016 #include <boost/process/detail/handler_base.hpp>
0017 #include <boost/process/detail/used_handles.hpp>
0018 #include <boost/process/detail/windows/file_descriptor.hpp>
0019 
0020 namespace boost { namespace process { namespace detail { namespace windows {
0021 
0022 template<int p1, int p2>
0023 struct null_out : public ::boost::process::detail::handler_base, ::boost::process::detail::uses_handles
0024 {
0025     file_descriptor sink {"NUL", file_descriptor::write}; //works because it gets destroyed AFTER launch.
0026 
0027     ::boost::winapi::HANDLE_ get_used_handles() const { return sink.handle(); }
0028 
0029     template <typename WindowsExecutor>
0030     void on_setup(WindowsExecutor &e) const;
0031 };
0032 
0033 template<>
0034 template<typename WindowsExecutor>
0035 void null_out<1,-1>::on_setup(WindowsExecutor &e) const
0036 {
0037     boost::winapi::SetHandleInformation(sink.handle(),
0038               boost::winapi::HANDLE_FLAG_INHERIT_,
0039               boost::winapi::HANDLE_FLAG_INHERIT_);
0040 
0041     e.startup_info.hStdOutput = sink.handle();
0042     e.startup_info.dwFlags   |= ::boost::winapi::STARTF_USESTDHANDLES_;
0043     e.inherit_handles = true;
0044 
0045 }
0046 
0047 template<>
0048 template<typename WindowsExecutor>
0049 void null_out<2,-1>::on_setup(WindowsExecutor &e) const
0050 {
0051     boost::winapi::SetHandleInformation(sink.handle(),
0052               boost::winapi::HANDLE_FLAG_INHERIT_,
0053               boost::winapi::HANDLE_FLAG_INHERIT_);
0054 
0055     e.startup_info.hStdError = sink.handle();
0056     e.startup_info.dwFlags  |= ::boost::winapi::STARTF_USESTDHANDLES_;
0057     e.inherit_handles = true;
0058 
0059 }
0060 
0061 template<>
0062 template<typename WindowsExecutor>
0063 void null_out<1,2>::on_setup(WindowsExecutor &e) const
0064 {
0065     boost::winapi::SetHandleInformation(sink.handle(),
0066             boost::winapi::HANDLE_FLAG_INHERIT_,
0067             boost::winapi::HANDLE_FLAG_INHERIT_);
0068 
0069     e.startup_info.hStdOutput = sink.handle();
0070     e.startup_info.hStdError  = sink.handle();
0071     e.startup_info.dwFlags   |= ::boost::winapi::STARTF_USESTDHANDLES_;
0072     e.inherit_handles = true;
0073 
0074 }
0075 
0076 }}}}
0077 
0078 #endif