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