From 1aea3c5d5a377e06eed7a76b6f968fa19e1b5bdf Mon Sep 17 00:00:00 2001 From: Benno Schulenberg Date: Sun, 19 Aug 2018 09:54:16 +0200 Subject: [PATCH] filtering: wait for the data-sending process to terminate too MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit When piping the buffer (or the marked region) to an external command, we should wait not only for the external command to terminate but also for the data-sending process, so that it will release its resources. This fixes https://savannah.gnu.org/bugs/?54499. With-help-from: Marco Diego Aurélio Mesquita --- src/text.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/text.c b/src/text.c index b5269029..aa5f0af9 100644 --- a/src/text.c +++ b/src/text.c @@ -1241,8 +1241,11 @@ bool execute_command(const char *command) openfile->undotop->strdata = mallocstrcpy(NULL, _("filtering")); } + /* Wait for the external command (and possibly data sender) to terminate. */ if (wait(NULL) == -1) nperror("wait"); + if (should_pipe && (wait(NULL) == -1)) + nperror("wait"); /* If it was changed, restore the handler for SIGINT. */ if (!setup_failed && sigaction(SIGINT, &oldaction, NULL) == -1) -- 2.17.1