]> git.ipfire.org Git - thirdparty/bash.git/blobdiff - execute_cmd.c
Bash-5.0 patch 17: better fix for reaping process substitution file descriptors
[thirdparty/bash.git] / execute_cmd.c
index 3864986d80c7d86787814c23500c732a1dfba714..4a05758d5f5ac9092e6d54ffc006490a41c39317 100644 (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 */