From 74bce85f1efdf66f4717562fabf0bc0a508bc691 Mon Sep 17 00:00:00 2001 From: "Christopher M. Punches" Date: Thu, 8 Feb 2024 10:02:53 +0000 Subject: [PATCH] Update src/lcpex/liblcpex.cpp --- src/lcpex/liblcpex.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/lcpex/liblcpex.cpp b/src/lcpex/liblcpex.cpp index 5a2941d..804870c 100644 --- a/src/lcpex/liblcpex.cpp +++ b/src/lcpex/liblcpex.cpp @@ -324,6 +324,9 @@ int execute( // wait for child to exit, capture status waitpid(pid, &status, 0); + // Drain the pipes before exiting + while (read_from_pipe(fd_child_stdout_pipe[READ_END], buf, BUFFER_SIZE) > 0); + while (read_from_pipe(fd_child_stderr_pipe[READ_END], buf, BUFFER_SIZE) > 0); if WIFEXITED(status) { return WEXITSTATUS(status);