filtering: wait for the data-sending process to terminate too

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 <marcodiegomesquita@gmail.com>
This commit is contained in:
Benno Schulenberg 2018-08-19 09:54:16 +02:00
parent 3218d8358a
commit ec339d3b08
1 changed files with 3 additions and 0 deletions

View File

@ -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)