X-Git-Url: http://git.tdb.fi/?a=blobdiff_plain;f=source%2Fcore%2Fwindows%2Fprocess.cpp;h=2f7b50547a4e8ff8ef493f58bcbdd90692379933;hb=817e584903996a041692640720a5a272d847a3c7;hp=7b1efd693aff45fce41594914b4d16dc2264de70;hpb=ea60f3548d4769c356b796cb27cd690cdfe4b6d9;p=libs%2Fcore.git diff --git a/source/core/windows/process.cpp b/source/core/windows/process.cpp index 7b1efd6..2f7b505 100644 --- a/source/core/windows/process.cpp +++ b/source/core/windows/process.cpp @@ -1,6 +1,7 @@ #include #include #include +#include #include "process.h" #include "process_private.h" @@ -56,10 +57,7 @@ void Process::execute(const string &command, bool path_search, const Arguments & { string cmdline = quote_argument(command); for(Arguments::const_iterator i=args.begin(); i!=args.end(); ++i) - { - cmdline += ' '; - cmdline += quote_argument(*i); - } + append(cmdline, " ", quote_argument(*i)); STARTUPINFO startup; startup.cb = sizeof(STARTUPINFO); @@ -82,9 +80,15 @@ void Process::execute(const string &command, bool path_search, const Arguments & } const char *cmdptr = (path_search ? 0 : command.c_str()); const char *wd = (work_dir.empty() ? 0 : work_dir.c_str()); - if(!CreateProcess(cmdptr, const_cast(cmdline.c_str()), 0, 0, false, 0, 0, wd, &startup, &priv->info)) + if(!CreateProcess(cmdptr, const_cast(cmdline.c_str()), 0, 0, true, 0, 0, wd, &startup, &priv->info)) throw system_error("CreateProcess"); - // XXX Should we close the duplicated handles? What if CreateProcess fails? + + if(redirect) + { + CloseHandle(startup.hStdInput); + CloseHandle(startup.hStdOutput); + CloseHandle(startup.hStdError); + } running = true;