aboutsummaryrefslogtreecommitdiff
path: root/ProcessUtils.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'ProcessUtils.cpp')
-rw-r--r--ProcessUtils.cpp11
1 files changed, 7 insertions, 4 deletions
diff --git a/ProcessUtils.cpp b/ProcessUtils.cpp
index e3effc9..efafc00 100644
--- a/ProcessUtils.cpp
+++ b/ProcessUtils.cpp
@@ -16,7 +16,7 @@ namespace {
spd->hPC = NULL;
}
- SubProcessData CreateSubProcess(LPCTSTR cmd, COORD size, HANDLE hInput, HANDLE hOutput, bool bUseConPty)
+ SubProcessData CreateSubProcess(LPCTSTR cmd, LPCTSTR wdir, COORD size, HANDLE hInput, HANDLE hOutput, bool bUseConPty)
{
SubProcessData spd = {};
@@ -87,8 +87,11 @@ namespace {
}
TCHAR localcmd[MAX_PATH];
+ TCHAR localwdir[MAX_PATH];
_tcscpy_s(localcmd, cmd);
- if (!CreateProcess(nullptr, localcmd, nullptr, nullptr, bInheritHandles, dwCreationFlags, nullptr, nullptr, &si.StartupInfo, &spd.pi))
+ if(wdir != nullptr)
+ _tcscpy_s(localwdir, wdir);
+ if (!CreateProcess(nullptr, localcmd, nullptr, nullptr, bInheritHandles, dwCreationFlags, nullptr, wdir == nullptr ? nullptr : localwdir, &si.StartupInfo, &spd.pi))
{
spd.hr = HRESULT_FROM_WIN32(GetLastError());
CleanupSubProcess(&spd);
@@ -101,7 +104,7 @@ namespace {
}
}
-SubProcessData CreateSubProcess(LPCTSTR cmd, COORD size, bool bUseConPty)
+SubProcessData CreateSubProcess(LPCTSTR cmd, LPCTSTR wdir, COORD size, bool bUseConPty)
{
SubProcessData spd = {};
@@ -119,7 +122,7 @@ SubProcessData CreateSubProcess(LPCTSTR cmd, COORD size, bool bUseConPty)
spd.hr = HRESULT_FROM_WIN32(GetLastError());
if (spd.hr == S_OK)
- spd = CreateSubProcess(cmd, size, hReadPipeInput, hWritePipeOutput, bUseConPty);
+ spd = CreateSubProcess(cmd, wdir, size, hReadPipeInput, hWritePipeOutput, bUseConPty);
if (spd.hr == S_OK)
{