X-Git-Url: http://git.tdb.fi/?a=blobdiff_plain;f=source%2Fcore%2Fwindows%2Fprocess.cpp;h=829365088115289bcdedc0ebc315911f3bf3175c;hb=5126e0aab38f902d6c54c517c9986ff0d0539afd;hp=2f7b50547a4e8ff8ef493f58bcbdd90692379933;hpb=ecc3d75ad9567cceee4302445d88c659b41a4899;p=libs%2Fcore.git diff --git a/source/core/windows/process.cpp b/source/core/windows/process.cpp index 2f7b505..8293650 100644 --- a/source/core/windows/process.cpp +++ b/source/core/windows/process.cpp @@ -14,19 +14,19 @@ string quote_argument(const string &arg) string result; bool need_quotes = false; bool backslash = false; - for(string::const_iterator i=arg.begin(); i!=arg.end(); ++i) + for(char c: arg) { - if(*i=='\\') + if(c=='\\') backslash = true; - else if(*i=='"') + else if(c=='"') { if(backslash) result += '\\'; result += '\\'; } - else if(*i==' ') + else if(c==' ') need_quotes = true; - result += *i; + result += c; } if(need_quotes) @@ -56,8 +56,8 @@ void Process::platform_get_self_info(Private &priv) void Process::execute(const string &command, bool path_search, const Arguments &args) { string cmdline = quote_argument(command); - for(Arguments::const_iterator i=args.begin(); i!=args.end(); ++i) - append(cmdline, " ", quote_argument(*i)); + for(const string &a: args) + append(cmdline, " ", quote_argument(a)); STARTUPINFO startup; startup.cb = sizeof(STARTUPINFO); @@ -109,6 +109,9 @@ bool Process::wait(bool block) { running = false; finished = true; + DWORD ec; + if(GetExitCodeProcess(priv->info.hProcess, &ec)) + exit_code = ec; } return finished;