Bash-5.0 patch 17: better fix for reaping process substitution file descriptors

This commit is contained in:
Chet Ramey
2020-04-24 11:05:06 -04:00
parent 6c6454cb18
commit 9e49d343e3
4 changed files with 30 additions and 38 deletions
+6 -20
View File
@@ -564,7 +564,7 @@ execute_command_internal (command, asynchronous, pipe_in, pipe_out,
volatile int save_line_number;
#if defined (PROCESS_SUBSTITUTION)
volatile int ofifo, nfifo, osize, saved_fifo;
volatile char *ofifo_list;
volatile void *ofifo_list;
#endif
if (breaking || continuing)
@@ -750,12 +750,14 @@ execute_command_internal (command, asynchronous, pipe_in, pipe_out,
reap_procsubs ();
# endif
if (variable_context != 0) /* XXX - also if sourcelevel != 0? */
/* XXX - also if sourcelevel != 0? */
if (variable_context != 0)
{
ofifo = num_fifos ();
ofifo_list = copy_fifo_list ((int *)&osize);
begin_unwind_frame ("internal_fifos");
add_unwind_protect (xfree, ofifo_list);
if (ofifo_list)
add_unwind_protect (xfree, ofifo_list);
saved_fifo = 1;
}
else
@@ -1099,26 +1101,10 @@ execute_command_internal (command, asynchronous, pipe_in, pipe_out,
{
nfifo = num_fifos ();
if (nfifo > ofifo)
close_new_fifos ((char *)ofifo_list, osize);
close_new_fifos ((void *)ofifo_list, osize);
free ((void *)ofifo_list);
discard_unwind_frame ("internal_fifos");
}
# if defined (HAVE_DEV_FD)
/* Reap process substitutions at the end of loops */
switch (command->type)
{
case cm_while:
case cm_until:
case cm_for:
case cm_group:
# if defined (ARITH_FOR_COMMAND)
case cm_arith_for:
# endif
reap_procsubs ();
default:
break;
}
# endif /* HAVE_DEV_FD */
#endif
/* Invert the return value if we have to */