3fb13f
From 2965eca924466a48c5597ac5c6c86d470e718908 Mon Sep 17 00:00:00 2001
3fb13f
From: Chet Ramey <chet.ramey@case.edu>
3fb13f
Date: Mon, 14 Nov 2016 14:27:35 -0500
3fb13f
Subject: [PATCH] Bash-4.4 patch 4
3fb13f
3fb13f
---
3fb13f
 jobs.c       | 15 +++++++++++++++
3fb13f
 jobs.h       |  1 +
3fb13f
 patchlevel.h |  2 +-
3fb13f
 subst.c      |  5 +----
3fb13f
 4 files changed, 18 insertions(+), 5 deletions(-)
3fb13f
3fb13f
diff --git a/jobs.c b/jobs.c
3fb13f
index cef3c79..fc96603 100644
3fb13f
--- a/jobs.c
3fb13f
+++ b/jobs.c
3fb13f
@@ -453,6 +453,21 @@ cleanup_the_pipeline ()
3fb13f
     discard_pipeline (disposer);
3fb13f
 }
3fb13f
 
3fb13f
+void
3fb13f
+discard_last_procsub_child ()
3fb13f
+{
3fb13f
+  PROCESS *disposer;
3fb13f
+  sigset_t set, oset;
3fb13f
+
3fb13f
+  BLOCK_CHILD (set, oset);
3fb13f
+  disposer = last_procsub_child;
3fb13f
+  last_procsub_child = (PROCESS *)NULL;
3fb13f
+  UNBLOCK_CHILD (oset);
3fb13f
+
3fb13f
+  if (disposer)
3fb13f
+    discard_pipeline (disposer);
3fb13f
+}
3fb13f
+
3fb13f
 struct pipeline_saver *
3fb13f
 alloc_pipeline_saver ()
3fb13f
 {
3fb13f
diff --git a/jobs.h b/jobs.h
3fb13f
index 4ba3513..6df0607 100644
3fb13f
--- a/jobs.h
3fb13f
+++ b/jobs.h
3fb13f
@@ -190,6 +190,7 @@ extern JOB **jobs;
3fb13f
 extern void making_children __P((void));
3fb13f
 extern void stop_making_children __P((void));
3fb13f
 extern void cleanup_the_pipeline __P((void));
3fb13f
+extern void discard_last_procsub_child __P((void));
3fb13f
 extern void save_pipeline __P((int));
3fb13f
 extern PROCESS *restore_pipeline __P((int));
3fb13f
 extern void start_pipeline __P((void));
3fb13f
diff --git a/patchlevel.h b/patchlevel.h
3fb13f
index e7e960c..c059f0b 100644
3fb13f
--- a/patchlevel.h
3fb13f
+++ b/patchlevel.h
3fb13f
@@ -25,6 +25,6 @@
3fb13f
    regexp `^#define[ 	]*PATCHLEVEL', since that's what support/mkversion.sh
3fb13f
    looks for to find the patch level (for the sccs version string). */
3fb13f
 
3fb13f
-#define PATCHLEVEL 3
3fb13f
+#define PATCHLEVEL 4
3fb13f
 
3fb13f
 #endif /* _PATCHLEVEL_H_ */
3fb13f
diff --git a/subst.c b/subst.c
3fb13f
index 4d498ef..298187d 100644
3fb13f
--- a/subst.c
3fb13f
+++ b/subst.c
3fb13f
@@ -5808,10 +5808,7 @@ process_substitute (string, open_for_read_in_child)
3fb13f
     {
3fb13f
 #if defined (JOB_CONTROL)
3fb13f
       if (last_procsub_child)
3fb13f
-	{
3fb13f
-	  discard_pipeline (last_procsub_child);
3fb13f
-	  last_procsub_child = (PROCESS *)NULL;
3fb13f
-	}
3fb13f
+	discard_last_procsub_child ();
3fb13f
       last_procsub_child = restore_pipeline (0);
3fb13f
 #endif
3fb13f
 
3fb13f
-- 
3fb13f
2.9.3
3fb13f