aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRadAd <adamgates84+github@gmail.com>2019-05-27 10:59:29 +1000
committerRadAd <adamgates84+github@gmail.com>2019-05-27 10:59:29 +1000
commitb32ca05cd422bc8faf3ce267d59b1421e8ca11ef (patch)
tree067318956e6e2381a6b1c5ad1636353dafd0dfc4
parent2cf31161aca9463a5d3a18106b628574699ab111 (diff)
downloadRadTerminal-b32ca05cd422bc8faf3ce267d59b1421e8ca11ef.tar.gz
RadTerminal-b32ca05cd422bc8faf3ce267d59b1421e8ca11ef.zip
Some fixes for non conpty.
-rw-r--r--ProcessUtils.cpp14
1 files changed, 10 insertions, 4 deletions
diff --git a/ProcessUtils.cpp b/ProcessUtils.cpp
index 8b8aa45..4a44ae3 100644
--- a/ProcessUtils.cpp
+++ b/ProcessUtils.cpp
@@ -25,6 +25,8 @@ namespace {
std::vector<BYTE> attrList;
si.StartupInfo.cb = sizeof(si);
+ BOOL bInheritHandles = FALSE;
+
if (bUseConPty)
{
spd.hr = CreatePseudoConsole(
@@ -81,11 +83,12 @@ namespace {
si.StartupInfo.hStdOutput = hOutput;
si.StartupInfo.hStdError = si.StartupInfo.hStdOutput;
dwCreationFlags |= CREATE_NO_WINDOW;
+ bInheritHandles = TRUE;
}
TCHAR localcmd[MAX_PATH];
wcscpy_s(localcmd, cmd);
- if (!CreateProcess(nullptr, localcmd, nullptr, nullptr, FALSE, dwCreationFlags, nullptr, nullptr, &si.StartupInfo, &spd.pi))
+ if (!CreateProcess(nullptr, localcmd, nullptr, nullptr, bInheritHandles, dwCreationFlags, nullptr, nullptr, &si.StartupInfo, &spd.pi))
{
spd.hr = HRESULT_FROM_WIN32(GetLastError());
CleanupSubProcess(&spd);
@@ -102,18 +105,21 @@ SubProcessData CreateSubProcess(LPCTSTR cmd, COORD size, bool bUseConPty)
{
SubProcessData spd = {};
+ SECURITY_ATTRIBUTES sa = {};
+ sa.bInheritHandle = !bUseConPty;
+
HANDLE hReadPipeInput = NULL;
HANDLE hWritePipeInput = NULL;
- if (spd.hr == S_OK && !CreatePipe(&hReadPipeInput, &hWritePipeInput, nullptr, 0))
+ if (spd.hr == S_OK && !CreatePipe(&hReadPipeInput, &hWritePipeInput, &sa, 0))
spd.hr = HRESULT_FROM_WIN32(GetLastError());
HANDLE hWritePipeOutput = NULL;
HANDLE hReadPipeOutput = NULL;
- if (spd.hr == S_OK && !CreatePipe(&hReadPipeOutput, &hWritePipeOutput, nullptr, 0))
+ if (spd.hr == S_OK && !CreatePipe(&hReadPipeOutput, &hWritePipeOutput, &sa, 0))
spd.hr = HRESULT_FROM_WIN32(GetLastError());
if (spd.hr == S_OK)
- spd = CreateSubProcess(cmd, size, hReadPipeInput, hWritePipeOutput, true);
+ spd = CreateSubProcess(cmd, size, hReadPipeInput, hWritePipeOutput, bUseConPty);
if (spd.hr == S_OK)
{