e00612c
From 3ba697465bc74fab513a26dea700cc82e9f4724e Mon Sep 17 00:00:00 2001
e00612c
From: Chet Ramey <chet.ramey@case.edu>
e00612c
Date: Sat, 20 Apr 2019 14:27:56 -0400
e00612c
Subject: [PATCH] Bash-5.0 patch 7: fix exec builtin leaving the terminal in
e00612c
 the wrong process group
e00612c
e00612c
---
e00612c
 jobs.c       | 12 +++++-------
e00612c
 patchlevel.h |  2 +-
e00612c
 2 files changed, 6 insertions(+), 8 deletions(-)
e00612c
e00612c
diff --git a/jobs.c b/jobs.c
e00612c
index ae3c54c6..6bc31dca 100644
e00612c
--- a/jobs.c
e00612c
+++ b/jobs.c
e00612c
@@ -4837,15 +4837,13 @@ void
e00612c
 end_job_control ()
e00612c
 {
e00612c
   if (job_control)
e00612c
-    {
e00612c
-      terminate_stopped_jobs ();
e00612c
+    terminate_stopped_jobs ();
e00612c
 
e00612c
-      if (original_pgrp >= 0)
e00612c
-	give_terminal_to (original_pgrp, 1);
e00612c
-    }
e00612c
+  if (original_pgrp >= 0 && terminal_pgrp != original_pgrp)
e00612c
+    give_terminal_to (original_pgrp, 1);
e00612c
 
e00612c
-  if (original_pgrp >= 0)
e00612c
-    setpgid (0, original_pgrp);
e00612c
+  if (original_pgrp >= 0 && setpgid (0, original_pgrp) == 0)
e00612c
+    shell_pgrp = original_pgrp;
e00612c
 }
e00612c
 
e00612c
 /* Restart job control by closing shell tty and reinitializing.  This is
e00612c
diff --git a/patchlevel.h b/patchlevel.h
e00612c
index 14bff9fc..deb9c5b7 100644
e00612c
--- a/patchlevel.h
e00612c
+++ b/patchlevel.h
e00612c
@@ -25,6 +25,6 @@
e00612c
    regexp `^#define[ 	]*PATCHLEVEL', since that's what support/mkversion.sh
e00612c
    looks for to find the patch level (for the sccs version string). */
e00612c
 
e00612c
-#define PATCHLEVEL 6
e00612c
+#define PATCHLEVEL 7
e00612c
 
e00612c
 #endif /* _PATCHLEVEL_H_ */
e00612c
-- 
e00612c
2.17.2
e00612c