executor.hpp
Go to the documentation of this file.
1
// Copyright (c) 2006, 2007 Julio M. Merino Vidal
2
// Copyright (c) 2008 Ilya Sokolov, Boris Schaeling
3
// Copyright (c) 2009 Boris Schaeling
4
// Copyright (c) 2010 Felipe Tanus, Boris Schaeling
5
// Copyright (c) 2011, 2012 Jeff Flinn, Boris Schaeling
6
//
7
// Distributed under the Boost Software License, Version 1.0. (See accompanying
8
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
9
10
#pragma once
11
12
#include <boost/fusion/algorithm/iteration/for_each.hpp>
13
#include <
boost/process/windows/child.hpp
>
14
15
#include <Windows.h>
16
17
namespace
boost::process::windows
18
{
19
20
struct
executor
21
{
22
executor
() :
23
exe
(0),
24
cmd_line
(0),
25
proc_attrs
(0),
26
thread_attrs
(0),
27
inherit_handles
(FALSE),
28
#
if
(_WIN32_WINNT >= 0x0600)
29
creation_flags
(EXTENDED_STARTUPINFO_PRESENT),
30
#else
31
creation_flags
(0),
32
#endif
33
env
(0),
34
work_dir
(0)
35
#
if
(_WIN32_WINNT >= 0x0600)
36
,
37
startup_info
(startup_info_ex.StartupInfo)
38
#endif
39
{
40
#if (_WIN32_WINNT >= 0x0600)
41
ZeroMemory(&startup_info_ex,
sizeof
(STARTUPINFOEX));
42
startup_info
.cb =
sizeof
(STARTUPINFOEX);
43
#else
44
ZeroMemory(&
startup_info
,
sizeof
(STARTUPINFO));
45
startup_info
.cb =
sizeof
(STARTUPINFO);
46
#endif
47
startup_info
.hStdInput = INVALID_HANDLE_VALUE;
48
startup_info
.hStdOutput = INVALID_HANDLE_VALUE;
49
startup_info
.hStdError = INVALID_HANDLE_VALUE;
50
}
51
52
struct
call_on_CreateProcess_setup
53
{
54
executor
&
e_
;
55
56
call_on_CreateProcess_setup
(
executor
& e) :
e_
(e)
57
{
58
}
59
60
template
<
class
Arg>
61
void
62
operator()
(Arg& arg)
const
63
{
64
arg.on_CreateProcess_setup(
e_
);
65
}
66
};
67
68
struct
call_on_CreateProcess_error
69
{
70
executor
&
e_
;
71
72
call_on_CreateProcess_error
(
executor
& e) :
e_
(e)
73
{
74
}
75
76
template
<
class
Arg>
77
void
78
operator()
(Arg& arg)
const
79
{
80
arg.on_CreateProcess_error(
e_
);
81
}
82
};
83
84
struct
call_on_CreateProcess_success
85
{
86
executor
&
e_
;
87
88
call_on_CreateProcess_success
(
executor
& e) :
e_
(e)
89
{
90
}
91
92
template
<
class
Arg>
93
void
94
operator()
(Arg& arg)
const
95
{
96
arg.on_CreateProcess_success(
e_
);
97
}
98
};
99
100
template
<
class
InitializerSequence>
101
child
102
operator()
(
const
InitializerSequence& seq)
103
{
104
boost::fusion::for_each(seq,
call_on_CreateProcess_setup
(*
this
));
105
106
if
(!::CreateProcess(
exe
,
107
cmd_line
,
108
proc_attrs
,
109
thread_attrs
,
110
inherit_handles
,
111
creation_flags
,
112
env
,
113
work_dir
,
114
&
startup_info
,
115
&
proc_info
))
116
{
117
boost::fusion::for_each(seq,
call_on_CreateProcess_error
(*
this
));
118
}
119
else
120
{
121
boost::fusion::for_each(seq,
call_on_CreateProcess_success
(*
this
));
122
}
123
124
return
child
(
proc_info
);
125
}
126
127
LPCTSTR
exe
;
128
LPTSTR
cmd_line
;
129
LPSECURITY_ATTRIBUTES
proc_attrs
;
130
LPSECURITY_ATTRIBUTES
thread_attrs
;
131
BOOL
inherit_handles
;
132
DWORD
creation_flags
;
133
LPVOID
env
;
134
LPCTSTR
work_dir
;
135
#if (_WIN32_WINNT >= 0x0600)
136
STARTUPINFOEX startup_info_ex;
137
STARTUPINFO&
startup_info
;
138
#else
139
STARTUPINFO
startup_info
;
140
#endif
141
PROCESS_INFORMATION
proc_info
;
142
};
143
144
}
// namespace boost::process::windows
if
if(!yyvaluep)
Definition
Grammar.cpp:645
boost::process::windows::child
Definition
child.hpp:20
boost::process::windows
Definition
child.hpp:17
boost::process::windows::executor::call_on_CreateProcess_error
Definition
executor.hpp:69
boost::process::windows::executor::call_on_CreateProcess_error::call_on_CreateProcess_error
call_on_CreateProcess_error(executor &e)
Definition
executor.hpp:72
boost::process::windows::executor::call_on_CreateProcess_error::operator()
void operator()(Arg &arg) const
Definition
executor.hpp:78
boost::process::windows::executor::call_on_CreateProcess_error::e_
executor & e_
Definition
executor.hpp:70
boost::process::windows::executor::call_on_CreateProcess_setup
Definition
executor.hpp:53
boost::process::windows::executor::call_on_CreateProcess_setup::operator()
void operator()(Arg &arg) const
Definition
executor.hpp:62
boost::process::windows::executor::call_on_CreateProcess_setup::e_
executor & e_
Definition
executor.hpp:54
boost::process::windows::executor::call_on_CreateProcess_setup::call_on_CreateProcess_setup
call_on_CreateProcess_setup(executor &e)
Definition
executor.hpp:56
boost::process::windows::executor::call_on_CreateProcess_success
Definition
executor.hpp:85
boost::process::windows::executor::call_on_CreateProcess_success::call_on_CreateProcess_success
call_on_CreateProcess_success(executor &e)
Definition
executor.hpp:88
boost::process::windows::executor::call_on_CreateProcess_success::operator()
void operator()(Arg &arg) const
Definition
executor.hpp:94
boost::process::windows::executor::call_on_CreateProcess_success::e_
executor & e_
Definition
executor.hpp:86
boost::process::windows::executor::operator()
child operator()(const InitializerSequence &seq)
Definition
executor.hpp:102
boost::process::windows::executor::executor
executor()
Definition
executor.hpp:22
boost::process::windows::executor::exe
LPCTSTR exe
Definition
executor.hpp:127
boost::process::windows::executor::cmd_line
LPTSTR cmd_line
Definition
executor.hpp:128
boost::process::windows::executor::creation_flags
DWORD creation_flags
Definition
executor.hpp:132
boost::process::windows::executor::proc_attrs
LPSECURITY_ATTRIBUTES proc_attrs
Definition
executor.hpp:129
boost::process::windows::executor::startup_info
STARTUPINFO startup_info
Definition
executor.hpp:139
boost::process::windows::executor::thread_attrs
LPSECURITY_ATTRIBUTES thread_attrs
Definition
executor.hpp:130
boost::process::windows::executor::inherit_handles
BOOL inherit_handles
Definition
executor.hpp:131
boost::process::windows::executor::proc_info
PROCESS_INFORMATION proc_info
Definition
executor.hpp:141
boost::process::windows::executor::work_dir
LPCTSTR work_dir
Definition
executor.hpp:134
boost::process::windows::executor::env
LPVOID env
Definition
executor.hpp:133
child.hpp
boost
process
windows
executor.hpp
Generated by
1.13.2