Teach a job to decide its job tree

Job trees come in two flavors: “placeholders” for jobs which are only fish
functions, and non-placeholders which need to track a pgid. This adds
logic to allow a job to decide if its parent's job tree is appropriate,
and allocating a new tree if not.
This commit is contained in:
ridiculousfish
2020-02-08 14:34:10 -08:00
parent 4e01c06256
commit e95bcfb074
11 changed files with 97 additions and 39 deletions

View File

@@ -1283,8 +1283,9 @@ end_execution_reason_t parse_execution_context_t::run_1_job(tnode_t<g::job> job_
// Clean up the job on failure or cancellation.
if (pop_result == end_execution_reason_t::ok) {
// Set the pgroup assignment mode, now that the job is populated.
// Set the pgroup assignment mode and job tree, now that the job is populated.
job->pgroup_provenance = get_pgroup_provenance(job, lineage);
job->job_tree = job_tree_t::decide_tree_for_job(job.get(), lineage.job_tree);
// Success. Give the job to the parser - it will clean it up.
parser->job_add(job);