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_PIPE_IN_HPP
\r
11 #define BOOST_PROCESS_WINDOWS_INITIALIZERS_PIPE_IN_HPP
\r
13 #include <boost/detail/winapi/process.hpp>
\r
14 #include <boost/detail/winapi/handles.hpp>
\r
15 #include <boost/process/detail/handler_base.hpp>
\r
17 namespace boost { namespace process { namespace detail { namespace windows {
\r
19 struct pipe_in : public ::boost::process::detail::handler_base
\r
21 ::boost::detail::winapi::HANDLE_ handle;
\r
23 pipe_in(::boost::detail::winapi::HANDLE_ handle) : handle(handle) {}
\r
25 template<typename T> //async_pipe
\r
26 pipe_in(T & p) : handle(p.native_source())
\r
28 p.assign_source(::boost::detail::winapi::INVALID_HANDLE_VALUE_);
\r
31 template <class WindowsExecutor>
\r
32 void on_setup(WindowsExecutor &e) const
\r
34 boost::detail::winapi::SetHandleInformation(handle,
\r
35 boost::detail::winapi::HANDLE_FLAG_INHERIT_,
\r
36 boost::detail::winapi::HANDLE_FLAG_INHERIT_);
\r
38 e.startup_info.hStdInput = handle;
\r
39 e.startup_info.dwFlags |= boost::detail::winapi::STARTF_USESTDHANDLES_;
\r
40 e.inherit_handles = true;
\r
42 template<typename WindowsExecutor>
\r
43 void on_error(WindowsExecutor &, const std::error_code &) const
\r
45 ::boost::detail::winapi::CloseHandle(handle);
\r
48 template<typename WindowsExecutor>
\r
49 void on_success(WindowsExecutor &) const
\r
51 ::boost::detail::winapi::CloseHandle(handle);
\r
57 struct async_pipe_in : public pipe_in
\r
61 template<typename AsyncPipe>
\r
62 async_pipe_in(AsyncPipe & p) : pipe_in(p.native_source()), pipe(p)
\r
66 template<typename Pipe, typename Executor>
\r
67 static void close(Pipe & pipe, Executor &)
\r
69 boost::system::error_code ec;
\r
70 std::move(pipe).source().close(ec);
\r
73 template<typename Executor>
\r
74 void on_error(Executor & exec, const std::error_code &)
\r
79 template<typename Executor>
\r
80 void on_success(Executor &exec)
\r