More aggressively inherit pgrps from parent jobs

Prior to this fix, a job would only inherit a pgrp from its parent if the
first command were external. There seems to be no reason for this
restriction and this causes tcsetgrp() churn, potentially cuasing SIGTTIN.
Switch to unconditionally inheriting a pgrp from parents.

This should fix most of #5765, the only remaining question is
tcsetpgrp from builtins.
This commit is contained in:
ridiculousfish
2019-04-07 13:08:37 -07:00
parent 4d62af7d40
commit f5bb8639d6
2 changed files with 13 additions and 5 deletions

View File

@@ -1027,11 +1027,9 @@ bool exec_job(parser_t &parser, shared_ptr<job_t> j) {
const std::shared_ptr<job_t> parent_job = j->get_parent();
// Perhaps inherit our parent's pgid and job control flag.
if (parent_job && j->processes.front()->type == process_type_t::external) {
if (parent_job->pgid != INVALID_PID) {
j->pgid = parent_job->pgid;
j->set_flag(job_flag_t::JOB_CONTROL, true);
}
if (parent_job && parent_job->pgid != INVALID_PID) {
j->pgid = parent_job->pgid;
j->set_flag(job_flag_t::JOB_CONTROL, true);
}
size_t stdout_read_limit = 0;