- more cleanups

This commit is contained in:
Dmytro Bogovych 2018-12-03 13:05:52 +02:00
parent 18b59691ef
commit 22acd46e30
1 changed files with 14 additions and 1 deletions

View File

@ -107,6 +107,7 @@ std::shared_ptr<std::thread> OsProcess::asyncExecCommand(const std::string& cmdl
char* cmdbuffer = (char*)_alloca(cmdline.size()+1);
strcpy(cmdbuffer, StringHelper::replace(cmdline, "/", "\\").c_str());
BOOL fSuccess = CreateProcessA( nullptr, cmdbuffer, nullptr, nullptr, TRUE,
CREATE_NEW_CONSOLE, nullptr, nullptr, &si, &pi);
if (! fSuccess)
@ -158,8 +159,20 @@ std::shared_ptr<std::thread> OsProcess::asyncExecCommand(const std::string& cmdl
if (buf[0])
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( hPipeRead );
if (finish_flag)
{
//GenerateConsoleCtrlEvent(CTRL_C_EVENT, 0);
// Close underlying process
//TerminateProcess(pi.hProcess, 3);
}
CloseHandle( pi.hProcess );
CloseHandle( pi.hThread );