aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBoris Kolpackov <boris@codesynthesis.com>2022-11-23 08:44:46 +0200
committerBoris Kolpackov <boris@codesynthesis.com>2022-11-23 08:44:46 +0200
commitb598f20fa916b389ea5a18837f1eac4a408856e6 (patch)
treef3a70aae1cd248cdd393b2c4fdf92b4e0fba6001
parentc579be859e9974b6f2ded0dc7623d61527bbe44b (diff)
Close any open pipe ends before waiting for process exit
-rw-r--r--libbutl/process.cxx11
1 files changed, 11 insertions, 0 deletions
diff --git a/libbutl/process.cxx b/libbutl/process.cxx
index 5b7682e..0bfff03 100644
--- a/libbutl/process.cxx
+++ b/libbutl/process.cxx
@@ -758,6 +758,13 @@ namespace butl
{
if (handle != 0)
{
+ // First close any open pipe ends for good measure but ignore any
+ // errors.
+ //
+ out_fd.reset ();
+ in_ofd.reset ();
+ in_efd.reset ();
+
int es;
int r (waitpid (handle, &es, 0));
handle = 0; // We have tried.
@@ -1960,6 +1967,10 @@ namespace butl
{
if (handle != 0)
{
+ out_fd.reset ();
+ in_ofd.reset ();
+ in_efd.reset ();
+
DWORD es;
DWORD e (NO_ERROR);
if (WaitForSingleObject (handle, INFINITE) != WAIT_OBJECT_0 ||