- more cleanups
This commit is contained in:
parent
18b59691ef
commit
22acd46e30
|
|
@ -89,7 +89,7 @@ std::shared_ptr<std::thread> OsProcess::asyncExecCommand(const std::string& cmdl
|
||||||
SECURITY_ATTRIBUTES saAttr = { sizeof(SECURITY_ATTRIBUTES), nullptr, FALSE };
|
SECURITY_ATTRIBUTES saAttr = { sizeof(SECURITY_ATTRIBUTES), nullptr, FALSE };
|
||||||
saAttr.bInheritHandle = TRUE; //Pipe handles are inherited by child process.
|
saAttr.bInheritHandle = TRUE; //Pipe handles are inherited by child process.
|
||||||
saAttr.lpSecurityDescriptor = nullptr;
|
saAttr.lpSecurityDescriptor = nullptr;
|
||||||
|
|
||||||
// Create a pipe to get results from child's stdout.
|
// Create a pipe to get results from child's stdout.
|
||||||
if ( !CreatePipe(&hPipeRead, &hPipeWrite, &saAttr, 0) )
|
if ( !CreatePipe(&hPipeRead, &hPipeWrite, &saAttr, 0) )
|
||||||
return std::shared_ptr<std::thread>();
|
return std::shared_ptr<std::thread>();
|
||||||
|
|
@ -107,6 +107,7 @@ std::shared_ptr<std::thread> OsProcess::asyncExecCommand(const std::string& cmdl
|
||||||
char* cmdbuffer = (char*)_alloca(cmdline.size()+1);
|
char* cmdbuffer = (char*)_alloca(cmdline.size()+1);
|
||||||
strcpy(cmdbuffer, StringHelper::replace(cmdline, "/", "\\").c_str());
|
strcpy(cmdbuffer, StringHelper::replace(cmdline, "/", "\\").c_str());
|
||||||
|
|
||||||
|
|
||||||
BOOL fSuccess = CreateProcessA( nullptr, cmdbuffer, nullptr, nullptr, TRUE,
|
BOOL fSuccess = CreateProcessA( nullptr, cmdbuffer, nullptr, nullptr, TRUE,
|
||||||
CREATE_NEW_CONSOLE, nullptr, nullptr, &si, &pi);
|
CREATE_NEW_CONSOLE, nullptr, nullptr, &si, &pi);
|
||||||
if (! fSuccess)
|
if (! fSuccess)
|
||||||
|
|
@ -158,8 +159,20 @@ std::shared_ptr<std::thread> OsProcess::asyncExecCommand(const std::string& cmdl
|
||||||
if (buf[0])
|
if (buf[0])
|
||||||
callback(StringHelper::trim(std::string(buf)));
|
callback(StringHelper::trim(std::string(buf)));
|
||||||
|
|
||||||
|
char ctrlc = 3;
|
||||||
|
//if (finish_flag)
|
||||||
|
// ::WriteFile(hPipeWrite, &ctrlc, 1, nullptr, nullptr);
|
||||||
|
|
||||||
|
// GenerateConsoleCtrlEvent(CTRL_BREAK_EVENT, pi.dwProcessId);
|
||||||
|
|
||||||
CloseHandle( hPipeWrite );
|
CloseHandle( hPipeWrite );
|
||||||
CloseHandle( hPipeRead );
|
CloseHandle( hPipeRead );
|
||||||
|
if (finish_flag)
|
||||||
|
{
|
||||||
|
//GenerateConsoleCtrlEvent(CTRL_C_EVENT, 0);
|
||||||
|
// Close underlying process
|
||||||
|
//TerminateProcess(pi.hProcess, 3);
|
||||||
|
}
|
||||||
CloseHandle( pi.hProcess );
|
CloseHandle( pi.hProcess );
|
||||||
CloseHandle( pi.hThread );
|
CloseHandle( pi.hThread );
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue