1 // Copyright (c) 2006, 2007 Julio M. Merino Vidal
\r
2 // Copyright (c) 2008 Ilya Sokolov, Boris Schaeling
\r
3 // Copyright (c) 2009 Boris Schaeling
\r
4 // Copyright (c) 2010 Felipe Tanus, Boris Schaeling
\r
5 // Copyright (c) 2011, 2012 Jeff Flinn, Boris Schaeling
\r
7 // Distributed under the Boost Software License, Version 1.0. (See accompanying
\r
8 // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
\r
10 #ifndef BOOST_PROCESS_WINDOWS_INITIALIZERS_NULL_OUT_HPP
\r
11 #define BOOST_PROCESS_WINDOWS_INITIALIZERS_NULL_OUT_HPP
\r
13 #include <boost/detail/winapi/process.hpp>
\r
14 #include <boost/detail/winapi/handles.hpp>
\r
15 #include <boost/detail/winapi/handle_info.hpp>
\r
16 #include <boost/process/detail/handler_base.hpp>
\r
17 #include <boost/process/detail/windows/file_descriptor.hpp>
\r
19 namespace boost { namespace process { namespace detail { namespace windows {
\r
21 template<int p1, int p2>
\r
22 struct null_out : public ::boost::process::detail::handler_base
\r
24 file_descriptor sink {"NUL", file_descriptor::write}; //works because it gets destroyed AFTER launch.
\r
26 template <typename WindowsExecutor>
\r
27 void on_setup(WindowsExecutor &e) const;
\r
31 template<typename WindowsExecutor>
\r
32 void null_out<1,-1>::on_setup(WindowsExecutor &e) const
\r
34 boost::detail::winapi::SetHandleInformation(sink.handle(),
\r
35 boost::detail::winapi::HANDLE_FLAG_INHERIT_,
\r
36 boost::detail::winapi::HANDLE_FLAG_INHERIT_);
\r
38 e.startup_info.hStdOutput = sink.handle();
\r
39 e.startup_info.dwFlags |= ::boost::detail::winapi::STARTF_USESTDHANDLES_;
\r
40 e.inherit_handles = true;
\r
45 template<typename WindowsExecutor>
\r
46 void null_out<2,-1>::on_setup(WindowsExecutor &e) const
\r
48 boost::detail::winapi::SetHandleInformation(sink.handle(),
\r
49 boost::detail::winapi::HANDLE_FLAG_INHERIT_,
\r
50 boost::detail::winapi::HANDLE_FLAG_INHERIT_);
\r
52 e.startup_info.hStdError = sink.handle();
\r
53 e.startup_info.dwFlags |= ::boost::detail::winapi::STARTF_USESTDHANDLES_;
\r
54 e.inherit_handles = true;
\r
59 template<typename WindowsExecutor>
\r
60 void null_out<1,2>::on_setup(WindowsExecutor &e) const
\r
62 boost::detail::winapi::SetHandleInformation(sink.handle(),
\r
63 boost::detail::winapi::HANDLE_FLAG_INHERIT_,
\r
64 boost::detail::winapi::HANDLE_FLAG_INHERIT_);
\r
66 e.startup_info.hStdOutput = sink.handle();
\r
67 e.startup_info.hStdError = sink.handle();
\r
68 e.startup_info.dwFlags |= ::boost::detail::winapi::STARTF_USESTDHANDLES_;
\r
69 e.inherit_handles = true;
\r