Petr Šabata 33fc6c
From 6c6454cb18d7cd30b3b26d5ba6479431e599f3ed Mon Sep 17 00:00:00 2001
Petr Šabata 33fc6c
From: Chet Ramey <chet.ramey@case.edu>
Petr Šabata 33fc6c
Date: Fri, 7 Feb 2020 15:20:38 -0500
Petr Šabata 33fc6c
Subject: [PATCH] Bash-5.0 patch 16: bash waits too long to reap /dev/fd
Petr Šabata 33fc6c
 process substitutions with loops and group commands
Petr Šabata 33fc6c
Petr Šabata 33fc6c
---
Petr Šabata 33fc6c
 execute_cmd.c | 16 ++++++++++++++++
Petr Šabata 33fc6c
 patchlevel.h  |  2 +-
Petr Šabata 33fc6c
 2 files changed, 17 insertions(+), 1 deletion(-)
Petr Šabata 33fc6c
Petr Šabata 33fc6c
diff --git a/execute_cmd.c b/execute_cmd.c
Petr Šabata 33fc6c
index f1d74bfe..3864986d 100644
Petr Šabata 33fc6c
--- a/execute_cmd.c
Petr Šabata 33fc6c
+++ b/execute_cmd.c
Petr Šabata 33fc6c
@@ -1103,6 +1103,22 @@ execute_command_internal (command, asynchronous, pipe_in, pipe_out,
Petr Šabata 33fc6c
       free ((void *)ofifo_list);
Petr Šabata 33fc6c
       discard_unwind_frame ("internal_fifos");
Petr Šabata 33fc6c
     }
Petr Šabata 33fc6c
+# if defined (HAVE_DEV_FD)
Petr Šabata 33fc6c
+  /* Reap process substitutions at the end of loops */
Petr Šabata 33fc6c
+  switch (command->type)
Petr Šabata 33fc6c
+    {
Petr Šabata 33fc6c
+    case cm_while:
Petr Šabata 33fc6c
+    case cm_until:
Petr Šabata 33fc6c
+    case cm_for:
Petr Šabata 33fc6c
+    case cm_group:
Petr Šabata 33fc6c
+#    if defined (ARITH_FOR_COMMAND)
Petr Šabata 33fc6c
+    case cm_arith_for:
Petr Šabata 33fc6c
+#    endif
Petr Šabata 33fc6c
+      reap_procsubs ();
Petr Šabata 33fc6c
+    default:
Petr Šabata 33fc6c
+      break;
Petr Šabata 33fc6c
+    }
Petr Šabata 33fc6c
+#  endif /* HAVE_DEV_FD */
Petr Šabata 33fc6c
 #endif
Petr Šabata 33fc6c
 
Petr Šabata 33fc6c
   /* Invert the return value if we have to */
Petr Šabata 33fc6c
diff --git a/patchlevel.h b/patchlevel.h
Petr Šabata 33fc6c
index 6e9ed3fc..9074f4dd 100644
Petr Šabata 33fc6c
--- a/patchlevel.h
Petr Šabata 33fc6c
+++ b/patchlevel.h
Petr Šabata 33fc6c
@@ -25,6 +25,6 @@
Petr Šabata 33fc6c
    regexp `^#define[ 	]*PATCHLEVEL', since that's what support/mkversion.sh
Petr Šabata 33fc6c
    looks for to find the patch level (for the sccs version string). */
Petr Šabata 33fc6c
 
Petr Šabata 33fc6c
-#define PATCHLEVEL 15
Petr Šabata 33fc6c
+#define PATCHLEVEL 16
Petr Šabata 33fc6c
 
Petr Šabata 33fc6c
 #endif /* _PATCHLEVEL_H_ */
Petr Šabata 33fc6c
-- 
Petr Šabata 33fc6c
2.25.1
Petr Šabata 33fc6c