summaryrefslogtreecommitdiff
path: root/libs/pbd/system_exec.cc
diff options
context:
space:
mode:
authorRobin Gareus <robin@gareus.org>2014-04-20 02:51:00 +0200
committerRobin Gareus <robin@gareus.org>2014-04-20 02:51:27 +0200
commit3552c17b918c9d7d4a6cf356e7914dd2c8e40e81 (patch)
tree9a6a313a09a4935f327fcc861a7ab11a2ef5cd58 /libs/pbd/system_exec.cc
parent1ea6321ad5da6c3ba3189d2f2337012c12ef8bb4 (diff)
fix SystemExec for windows
Diffstat (limited to 'libs/pbd/system_exec.cc')
-rw-r--r--libs/pbd/system_exec.cc17
1 files changed, 14 insertions, 3 deletions
diff --git a/libs/pbd/system_exec.cc b/libs/pbd/system_exec.cc
index 7814cce96b..98324039a6 100644
--- a/libs/pbd/system_exec.cc
+++ b/libs/pbd/system_exec.cc
@@ -23,6 +23,7 @@
#include <string.h>
#include <errno.h>
#include <unistd.h>
+#include <algorithm>
#include <assert.h>
@@ -266,10 +267,16 @@ SystemExec::make_wargs(char **a) {
std::string wa = cmd;
if (cmd[0] != '"' && cmd[cmd.size()] != '"' && strchr(cmd.c_str(), ' ')) { wa = "\"" + cmd + "\""; }
std::replace(cmd.begin(), cmd.end(), '/', '\\' );
- char **tmp = a;
+ char **tmp = ++a;
while (tmp && *tmp) {
wa.append(" \"");
- wa.append(*tmp);
+ std::string arg(*tmp);
+ size_t start_pos = 0;
+ while((start_pos = arg.find("\\", start_pos)) != std::string::npos) {
+ arg.replace(start_pos, 1, "\\\\");
+ start_pos += 2;
+ }
+ wa.append(arg);
wa.append("\"");
tmp++;
}
@@ -416,7 +423,11 @@ SystemExec::output_interposer()
if (bytesAvail < 1) {Sleep(500); printf("N/A\n"); continue;}
#endif
if (stdoutP[0] == INVALID_HANDLE_VALUE) break;
- if (!ReadFile(stdoutP[0], data, BUFSIZ, &bytesRead, 0)) break;
+ if (!ReadFile(stdoutP[0], data, BUFSIZ, &bytesRead, 0)) {
+ DWORD err = GetLastError();
+ if (err == ERROR_IO_PENDING) continue;
+ break;
+ }
if (bytesRead < 1) continue; /* actually not needed; but this is safe. */
data[bytesRead] = 0;
ReadStdout(data, bytesRead);/* EMIT SIGNAL */