about summary refs log tree commit diff
diff options
context:
space:
mode:
authorBarton E. Schaefer <schaefer@zsh.org>2013-12-25 16:20:49 -0800
committerBarton E. Schaefer <schaefer@zsh.org>2013-12-25 16:20:49 -0800
commit15f4843c676cf73a854b35ec7fddb2cfe6be6fbe (patch)
treea4840ce2d9f5ba8b981feafe611472f690c87b0a
parentaede5c52bf557f89d1d09fa5430186af6e295241 (diff)
downloadzsh-15f4843c676cf73a854b35ec7fddb2cfe6be6fbe.tar.gz
zsh-15f4843c676cf73a854b35ec7fddb2cfe6be6fbe.tar.xz
zsh-15f4843c676cf73a854b35ec7fddb2cfe6be6fbe.zip
32178: fix another acquire_pgrp() infinite loop
-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) {