Petr Šabata 33fc6c
From 3ba697465bc74fab513a26dea700cc82e9f4724e Mon Sep 17 00:00:00 2001
Petr Šabata 33fc6c
From: Chet Ramey <chet.ramey@case.edu>
Petr Šabata 33fc6c
Date: Sat, 20 Apr 2019 14:27:56 -0400
Petr Šabata 33fc6c
Subject: [PATCH] Bash-5.0 patch 7: fix exec builtin leaving the terminal in
Petr Šabata 33fc6c
 the wrong process group
Petr Šabata 33fc6c
Petr Šabata 33fc6c
---
Petr Šabata 33fc6c
 jobs.c       | 12 +++++-------
Petr Šabata 33fc6c
 patchlevel.h |  2 +-
Petr Šabata 33fc6c
 2 files changed, 6 insertions(+), 8 deletions(-)
Petr Šabata 33fc6c
Petr Šabata 33fc6c
diff --git a/jobs.c b/jobs.c
Petr Šabata 33fc6c
index ae3c54c6..6bc31dca 100644
Petr Šabata 33fc6c
--- a/jobs.c
Petr Šabata 33fc6c
+++ b/jobs.c
Petr Šabata 33fc6c
@@ -4837,15 +4837,13 @@ void
Petr Šabata 33fc6c
 end_job_control ()
Petr Šabata 33fc6c
 {
Petr Šabata 33fc6c
   if (job_control)
Petr Šabata 33fc6c
-    {
Petr Šabata 33fc6c
-      terminate_stopped_jobs ();
Petr Šabata 33fc6c
+    terminate_stopped_jobs ();
Petr Šabata 33fc6c
 
Petr Šabata 33fc6c
-      if (original_pgrp >= 0)
Petr Šabata 33fc6c
-	give_terminal_to (original_pgrp, 1);
Petr Šabata 33fc6c
-    }
Petr Šabata 33fc6c
+  if (original_pgrp >= 0 && terminal_pgrp != original_pgrp)
Petr Šabata 33fc6c
+    give_terminal_to (original_pgrp, 1);
Petr Šabata 33fc6c
 
Petr Šabata 33fc6c
-  if (original_pgrp >= 0)
Petr Šabata 33fc6c
-    setpgid (0, original_pgrp);
Petr Šabata 33fc6c
+  if (original_pgrp >= 0 && setpgid (0, original_pgrp) == 0)
Petr Šabata 33fc6c
+    shell_pgrp = original_pgrp;
Petr Šabata 33fc6c
 }
Petr Šabata 33fc6c
 
Petr Šabata 33fc6c
 /* Restart job control by closing shell tty and reinitializing.  This is
Petr Šabata 33fc6c
diff --git a/patchlevel.h b/patchlevel.h
Petr Šabata 33fc6c
index 14bff9fc..deb9c5b7 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 6
Petr Šabata 33fc6c
+#define PATCHLEVEL 7
Petr Šabata 33fc6c
 
Petr Šabata 33fc6c
 #endif /* _PATCHLEVEL_H_ */
Petr Šabata 33fc6c
-- 
Petr Šabata 33fc6c
2.17.2
Petr Šabata 33fc6c