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

View file

@ -14,3 +14,13 @@ for {set x 0} {$x<15} {incr x} {
# 'not' because we expect to have no jobs, in which case `jobs` will return false # 'not' because we expect to have no jobs, in which case `jobs` will return false
send_line "not jobs" send_line "not jobs"
expect_prompt "jobs: There are no jobs" {} unmatched { puts stderr "Should be no jobs" } expect_prompt "jobs: There are no jobs" {} unmatched { puts stderr "Should be no jobs" }
send_line "function inner ; command true ; end; function outer; inner; end"
expect_prompt
for {set x 0} {$x<15} {incr x} {
send_line "outer | $fish_test_helper become_foreground_then_print_stderr ; or exit 1"
expect_prompt "become_foreground_then_print_stderr done" {} unmatched { puts stderr "fish_test_helper become_foreground_then_print_stderr failed"}
}
send_line "not jobs"
expect_prompt "jobs: There are no jobs" {} unmatched { puts stderr "Should be no jobs" }