mirror of
git://git.code.sf.net/p/zsh/code
synced 2025-09-03 10:21:46 +02:00
44864: Avoid inifinite loop in tty init.
If we can't grab the terminal in interactive mode, give up after 100 goes. This is a completely arbitrary choice; we simply don't know what in the system could change the result of looping further.
This commit is contained in:
parent
5be28dac5d
commit
8c25d92e11
2 changed files with 20 additions and 2 deletions
|
@ -1,5 +1,9 @@
|
|||
2019-10-28 Peter Stephenson <p.stephenson@samsung.com>
|
||||
|
||||
* 44864: Src/jobs.c: Avoid infinite loop in interactive mode
|
||||
when trying to grab terminal. Fail after 100 goes (arbitrary
|
||||
choice).
|
||||
|
||||
* Sebastian: 44865: configure.ac: Try harder to link in curses
|
||||
even if not needed for termcap variables.
|
||||
|
||||
|
|
18
Src/jobs.c
18
Src/jobs.c
|
@ -2933,6 +2933,7 @@ acquire_pgrp(void)
|
|||
sigaddset(&blockset, SIGTTOU);
|
||||
sigaddset(&blockset, SIGTSTP);
|
||||
oldset = signal_block(blockset);
|
||||
int loop_count = 0;
|
||||
while ((ttpgrp = gettygrp()) != -1 && ttpgrp != mypgrp) {
|
||||
mypgrp = GETPGRP();
|
||||
if (mypgrp == mypid) {
|
||||
|
@ -2948,8 +2949,21 @@ 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 */
|
||||
if (mypgrp == lastpgrp) {
|
||||
if (!interact)
|
||||
break; /* Unlikely that pgrp will ever change */
|
||||
if (++loop_count == 100)
|
||||
{
|
||||
/*
|
||||
* It's time to give up. The count is arbitrary;
|
||||
* this is just to fix up unusual cases, so it's
|
||||
* left large in an attempt not to break normal
|
||||
* cases where there's some delay in the system
|
||||
* setting up the terminal.
|
||||
*/
|
||||
break;
|
||||
}
|
||||
}
|
||||
lastpgrp = mypgrp;
|
||||
}
|
||||
if (mypgrp != mypid) {
|
||||
|
|
Loading…
Reference in a new issue