summary refs log tree commit diff
diff options
context:
space:
mode:
-rw-r--r--ChangeLog6
-rw-r--r--Src/jobs.c4
2 files changed, 9 insertions, 1 deletions
diff --git a/ChangeLog b/ChangeLog
index 9efa11950..031269a8d 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,4 +1,8 @@
-2013-12-21  Barton E. Schaefer  <schaefer@brasslantern.com>
+2013-12-25  Barton E. Schaefer  <schaefer@zsh.org>
+
+	* 32178: Src/jobs.c: fix another acquire_pgrp() infinite loop
+
+2013-12-21  Barton E. Schaefer  <schaefer@zsh.org>
 
 	* PWS + Bart: 32176: plug additional descriptor leaks causing
 	deadlock via different code paths; expand regression test
diff --git a/Src/jobs.c b/Src/jobs.c
index a32117217..871946598 100644
--- a/Src/jobs.c
+++ b/Src/jobs.c
@@ -2619,6 +2619,7 @@ acquire_pgrp(void)
     sigset_t blockset, oldset;
 
     if ((mypgrp = GETPGRP()) > 0) {
+	long lastpgrp = mypgrp;
 	sigemptyset(&blockset);
 	sigaddset(&blockset, SIGTTIN);
 	sigaddset(&blockset, SIGTTOU);
@@ -2639,6 +2640,9 @@ acquire_pgrp(void)
 	    if (read(0, NULL, 0) != 0) {} /* Might generate SIGT* */
 	    signal_block(blockset);
 	    mypgrp = GETPGRP();
+	    if (mypgrp == lastpgrp && !interact)
+		break; /* Unlikely that pgrp will ever change */
+	    lastpgrp = mypgrp;
 	}
 	if (mypgrp != mypid) {
 	    if (setpgrp(0, 0) == 0) {