Skip to content

Commit

Permalink
use explicit wide char CreateProcessW
Browse files Browse the repository at this point in the history
  • Loading branch information
graph committed Aug 24, 2024
1 parent d5afa84 commit 1b35a48
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions src/cpp/subprocess/ProcessBuilder_windows.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -48,11 +48,14 @@ namespace subprocess {
saAttr.bInheritHandle = TRUE;
saAttr.lpSecurityDescriptor = NULL;


STARTUPINFO siStartInfo = {0};
#ifdef UNICODE
STARTUPINFOW siStartInfo = {0};
#else
STARTUPINFOA siStartInfo = {0};
#endif
BOOL bSuccess = FALSE;

siStartInfo.cb = sizeof(STARTUPINFO);
siStartInfo.cb = sizeof(siStartInfo);
siStartInfo.hStdInput = GetStdHandle(STD_INPUT_HANDLE);
siStartInfo.hStdOutput = GetStdHandle(STD_OUTPUT_HANDLE);
siStartInfo.hStdError = GetStdHandle(STD_ERROR_HANDLE);
Expand Down Expand Up @@ -128,12 +131,12 @@ namespace subprocess {
if (this->new_process_group) {
process_flags |= CREATE_NEW_PROCESS_GROUP;
}

process.cwd = this->cwd;
// Create the child process.
#ifdef UNICODE // CreateProcessW
std::u16string cmd_args{ utf8_to_utf16(args) };
bSuccess = CreateProcess(
bSuccess = CreateProcessW(
(LPCWSTR)utf8_to_utf16(program).c_str(),
(LPWSTR)cmd_args.data(), // command line
NULL, // process security attributes
Expand Down

0 comments on commit 1b35a48

Please sign in to comment.