@@ -31,6 +31,8 @@ enum : std::uint16_t { InvalidExitCode = 999 };
3131ExecuteCommand::ExecuteCommand (std::string command)
3232 : ChildStdOut_Rd(nullptr ),
3333 ChildStdOut_Wd(nullptr ),
34+ ChildStdErr_Rd(nullptr ),
35+ ChildStdErr_Wd(nullptr ),
3436 base_command(std::move(command)) {
3537 this ->CreateChildPipes ();
3638 this ->SetupExecute ();
@@ -39,6 +41,8 @@ ExecuteCommand::ExecuteCommand(std::string command)
3941ExecuteCommand::ExecuteCommand (std::string arg, const StrList& args)
4042 : ChildStdOut_Rd(nullptr ),
4143 ChildStdOut_Wd(nullptr ),
44+ ChildStdErr_Rd(nullptr ),
45+ ChildStdErr_Wd(nullptr ),
4246 base_command(std::move(arg)) {
4347 for (const auto & argp : args) {
4448 this ->command_args .push_back (argp);
@@ -51,6 +55,8 @@ ExecuteCommand& ExecuteCommand::operator=(
5155 ExecuteCommand&& execute_command) noexcept {
5256 this ->ChildStdOut_Rd = std::move (execute_command.ChildStdOut_Rd );
5357 this ->ChildStdOut_Wd = std::move (execute_command.ChildStdOut_Wd );
58+ this ->ChildStdErr_Rd = std::move (execute_command.ChildStdErr_Rd );
59+ this ->ChildStdErr_Wd = std::move (execute_command.ChildStdErr_Wd );
5460 this ->procInfo = std::move (execute_command.procInfo );
5561 this ->startInfo = std::move (execute_command.startInfo );
5662 this ->saAttr = std::move (execute_command.saAttr );
@@ -59,6 +65,7 @@ ExecuteCommand& ExecuteCommand::operator=(
5965 this ->base_command = std::move (execute_command.base_command );
6066 this ->command_args = std::move (execute_command.command_args );
6167 this ->child_out_future = std::move (execute_command.child_out_future );
68+ this ->child_err_future = std::move (execute_command.child_err_future );
6269 this ->exit_code_future = std::move (exit_code_future);
6370 return *this ;
6471}
@@ -76,7 +83,7 @@ void ExecuteCommand::SetupExecute() {
7683 // This structure specifies the STDIN and STDOUT handles for redirection.
7784 ZeroMemory (&si_start_info, sizeof (STARTUPINFOW));
7885 si_start_info.cb = sizeof (STARTUPINFOW);
79- si_start_info.hStdError = this ->ChildStdOut_Wd ;
86+ si_start_info.hStdError = this ->ChildStdErr_Wd ;
8087 si_start_info.hStdOutput = this ->ChildStdOut_Wd ;
8188 si_start_info.dwFlags |= STARTF_USESTDHANDLES;
8289 this ->procInfo = pi_proc_info;
@@ -162,6 +169,7 @@ bool ExecuteCommand::ExecuteToolChainChild() {
162169 // determine when child proc is done
163170 free (nc_command_line);
164171 CloseHandle (this ->ChildStdOut_Wd );
172+ CloseHandle (this ->ChildStdErr_Wd );
165173 return true ;
166174}
167175
0 commit comments