diff --git a/subprocess.hpp b/subprocess.hpp index 8c74c2b..7bd2d0f 100755 --- a/subprocess.hpp +++ b/subprocess.hpp @@ -1330,6 +1330,7 @@ private: #ifdef __USING_WINDOWS__ HANDLE process_handle_; + std::future cleanup_future_; #endif bool defer_process_start_ = false; @@ -1555,7 +1556,7 @@ inline void Popen::execute_process() noexcept(false) this->process_handle_ = piProcInfo.hProcess; - std::async(std::launch::async, [this] { + this->cleanup_future_ = std::async(std::launch::async, [this] { WaitForSingleObject(this->process_handle_, INFINITE); CloseHandle(this->stream_.g_hChildStd_ERR_Wr);