From ecc3d75ad9567cceee4302445d88c659b41a4899 Mon Sep 17 00:00:00 2001 From: Mikko Rasa Date: Sun, 22 Aug 2021 12:41:28 +0300 Subject: [PATCH] Close duplicated handles after starting a new process --- source/core/windows/process.cpp | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) 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; -- 2.43.0