]> git.tdb.fi Git - libs/core.git/blobdiff - source/core/windows/process.cpp
Close duplicated handles after starting a new process
[libs/core.git] / source / core / windows / process.cpp
index 6123fa7aad6ab73c67beae3df08f3141cfbcfae8..2f7b50547a4e8ff8ef493f58bcbdd90692379933 100644 (file)
@@ -82,7 +82,13 @@ void Process::execute(const string &command, bool path_search, const Arguments &
        const char *wd = (work_dir.empty() ? 0 : work_dir.c_str());
        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?
+
+       if(redirect)
+       {
+               CloseHandle(startup.hStdInput);
+               CloseHandle(startup.hStdOutput);
+               CloseHandle(startup.hStdError);
+       }
 
        running = true;