From: Mikko Rasa Date: Sun, 22 Aug 2021 09:41:28 +0000 (+0300) Subject: Close duplicated handles after starting a new process X-Git-Url: http://git.tdb.fi/?p=libs%2Fcore.git;a=commitdiff_plain;h=ecc3d75ad9567cceee4302445d88c659b41a4899 Close duplicated handles after starting a new process --- diff --git a/source/core/windows/process.cpp b/source/core/windows/process.cpp index 6123fa7..2f7b505 100644 --- a/source/core/windows/process.cpp +++ b/source/core/windows/process.cpp @@ -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(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;