aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFeng Xiao <xfxyjwf@gmail.com>2018-09-10 13:47:08 -0700
committerGitHub <noreply@github.com>2018-09-10 13:47:08 -0700
commitf8cd9b0faca6edc2bc0d52b72b2729001afd15ff (patch)
tree8b96588cf8adfe27f55d3fc3c4ed35d5ab1032e7
parent3bf0245fd2a99081d4077e2c867a8488dc15e636 (diff)
parent4e5ae963e855fb201aa70f2784a62c70ca3c6580 (diff)
downloadprotobuf-f8cd9b0faca6edc2bc0d52b72b2729001afd15ff.tar.gz
protobuf-f8cd9b0faca6edc2bc0d52b72b2729001afd15ff.tar.bz2
protobuf-f8cd9b0faca6edc2bc0d52b72b2729001afd15ff.zip
Merge pull request #5105 from sigurdm/invoke_plugin_via_cmd
On Windows invoke plugins using cmd.exe
-rw-r--r--src/google/protobuf/compiler/subprocess.cc9
1 files changed, 5 insertions, 4 deletions
diff --git a/src/google/protobuf/compiler/subprocess.cc b/src/google/protobuf/compiler/subprocess.cc
index 2e5a89ac..5bd3d435 100644
--- a/src/google/protobuf/compiler/subprocess.cc
+++ b/src/google/protobuf/compiler/subprocess.cc
@@ -124,14 +124,15 @@ void Subprocess::Start(const string& program, SearchMode search_mode) {
<< Win32ErrorMessage(GetLastError());
}
- // CreateProcess() mutates its second parameter. WTF?
- char* name_copy = portable_strdup(program.c_str());
+ // Invoking cmd.exe allows for '.bat' files from the path as well as '.exe'.
+ // Using a malloc'ed string because CreateProcess() can mutate its second parameter. (WTF).
+ char *command_line = portable_strdup(("cmd.exe /c \"" + program + "\"").c_str());
// Create the process.
PROCESS_INFORMATION process_info;
if (CreateProcessA((search_mode == SEARCH_PATH) ? NULL : program.c_str(),
- (search_mode == SEARCH_PATH) ? name_copy : NULL,
+ (search_mode == SEARCH_PATH) ? command_line : NULL,
NULL, // process security attributes
NULL, // thread security attributes
TRUE, // inherit handles?
@@ -152,7 +153,7 @@ void Subprocess::Start(const string& program, SearchMode search_mode) {
CloseHandleOrDie(stdin_pipe_read);
CloseHandleOrDie(stdout_pipe_write);
- free(name_copy);
+ free(command_line);
}
bool Subprocess::Communicate(const Message& input, Message* output,