-
Notifications
You must be signed in to change notification settings - Fork 274
Piped communication on Windows #6180
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 1 commit
ffacdea
20c51db
fab21fe
c90b2fe
803de49
dfd28af
3f9fe4a
c62310f
8510283
f60acac
cec11e1
f7e4440
e530e4a
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -101,6 +101,19 @@ | |
|
||
# define BUFSIZE 2048 | ||
|
||
#ifdef _WIN32 | ||
std::wstring process_windows_args(const std::vector<std::string> commandvec) | ||
{ | ||
std::wstring result = widen(commandvec[0]); | ||
for(int i = 1; i < commandvec.size(); i++) | ||
{ | ||
result.append(L" "); | ||
result.append(quote_windows_arg(widen(commandvec[i]))); | ||
} | ||
return result; | ||
} | ||
#endif | ||
|
||
piped_processt::piped_processt(const std::vector<std::string> commandvec) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I recognise this was here before, but any insight as to why this isn't being passed as a reference? The There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. No insight, but fixed now. |
||
{ | ||
// Default state | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Would it be possible to split up this mega-function a bit? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Split out a small helper function, but the function is pretty straightforward, just many lines due to many arguments to function calls to create Windows processes/pipes (also lots of commends/explanation). |
||
|
@@ -193,13 +206,7 @@ piped_processt::piped_processt(const std::vector<std::string> commandvec) | |
start_info.hStdOutput = child_std_OUT_Wr; | ||
start_info.hStdInput = child_std_IN_Rd; | ||
start_info.dwFlags |= STARTF_USESTDHANDLES; | ||
// Unpack the command into a single string for Windows API | ||
thomasspriggs marked this conversation as resolved.
Show resolved
Hide resolved
|
||
std::wstring cmdline = widen(commandvec[0]); | ||
for(int i = 1; i < commandvec.size(); i++) | ||
{ | ||
cmdline.append(L" "); | ||
cmdline.append(quote_windows_arg(widen(commandvec[i]))); | ||
} | ||
const std::wstring cmdline = process_windows_args(commandvec); | ||
thomasspriggs marked this conversation as resolved.
Show resolved
Hide resolved
|
||
// Note that we do NOT free this since it becomes part of the child | ||
// and causes heap corruption in Windows if we free! | ||
const BOOL success = CreateProcessW( | ||
|
Uh oh!
There was an error while loading. Please reload this page.