]> git.tdb.fi Git - libs/core.git/blobdiff - source/core/windows/process.cpp
Enable inheriting handles in CreateProcess
[libs/core.git] / source / core / windows / process.cpp
index 7b1efd693aff45fce41594914b4d16dc2264de70..6123fa7aad6ab73c67beae3df08f3141cfbcfae8 100644 (file)
@@ -1,6 +1,7 @@
 #include <windows.h>
 #include <msp/core/systemerror.h>
 #include <msp/io/handle_private.h>
+#include <msp/strings/utils.h>
 #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,7 +80,7 @@ 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<char *>(cmdline.c_str()), 0, 0, false, 0, 0, wd, &startup, &priv->info))
+       if(!CreateProcess(cmdptr, const_cast<char *>(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?