From b598f20fa916b389ea5a18837f1eac4a408856e6 Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Wed, 23 Nov 2022 08:44:46 +0200 Subject: Close any open pipe ends before waiting for process exit --- libbutl/process.cxx | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'libbutl') 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 || -- cgit v1.1