diff options
Diffstat (limited to 'Src/jobs.c')
-rw-r--r-- | Src/jobs.c | 18 |
1 files changed, 16 insertions, 2 deletions
diff --git a/Src/jobs.c b/Src/jobs.c index 50751decb..c06cb9c79 100644 --- a/Src/jobs.c +++ b/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) { |