Be less aggressive about reclaiming the foreground pgrp

Prior to this fix, in every call to job_continue, fish would reclaim the
foreground pgrp. This would cause other jobs in the pipeline (which may
have another pgrp) to receive SIGTTIN / SIGTTOU.

Only reclaim the foreground pgrp if it was held at the point of job_continue.

This partially addresses #5765
This commit is contained in:
ridiculousfish
2019-04-06 20:00:52 -07:00
parent 23d88e0e03
commit 39a9740997
5 changed files with 12 additions and 7 deletions

View File

@@ -1021,6 +1021,9 @@ bool exec_job(parser_t &parser, shared_ptr<job_t> j) {
return true;
}
// Check to see if we should reclaim the foreground pgrp after the job finishes or stops.
const bool reclaim_foreground_pgrp = (tcgetpgrp(STDIN_FILENO) == getpgrp());
const std::shared_ptr<job_t> parent_job = j->get_parent();
// Perhaps inherit our parent's pgid and job control flag.
@@ -1120,7 +1123,7 @@ bool exec_job(parser_t &parser, shared_ptr<job_t> j) {
return false;
}
j->continue_job(false);
j->continue_job(reclaim_foreground_pgrp, false);
return true;
}