Finish renaming job tree to job group

Some "tree" terminology was still there.
This commit is contained in:
ridiculousfish 2020-07-11 17:05:42 -07:00
parent 765c48afa4
commit 2e5222ffe8
3 changed files with 20 additions and 19 deletions

View File

@ -1332,7 +1332,7 @@ end_execution_reason_t parse_execution_context_t::run_1_job(const ast::job_t &jo
// Clean up the job on failure or cancellation.
if (pop_result == end_execution_reason_t::ok) {
// Set the pgroup assignment mode and job group, now that the job is populated.
job_group_t::populate_tree_for_job(job.get(), ctx.job_group);
job_group_t::populate_group_for_job(job.get(), ctx.job_group);
assert(job->group && "Should have a job group");
// Success. Give the job to the parser - it will clean it up.

View File

@ -151,7 +151,7 @@ bool job_t::should_report_process_exits() const {
// Only report root job exits.
// For example in `ls | begin ; cat ; end` we don't need to report the cat sub-job.
if (!flags().is_tree_root) {
if (!flags().is_group_root) {
return false;
}
@ -257,34 +257,35 @@ void job_group_t::set_pgid(pid_t pgid) {
maybe_t<pid_t> job_group_t::get_pgid() const { return pgid_; }
void job_group_t::populate_tree_for_job(job_t *job, const job_group_ref_t &proposed) {
void job_group_t::populate_group_for_job(job_t *job, const job_group_ref_t &proposed) {
assert(!job->group && "Job already has a group");
// Note there's three cases to consider:
// nullptr -> this is a root job, there is no inherited job group
// internal -> the parent is running as part of a simple function execution
// We may need to create a new job group if we are going to fork.
// non-internal -> we are running as part of a real pipeline
// Decide if this job can use an internal tree.
// Decide if this job can use an internal group.
// This is true if it's a simple foreground execution of an internal proc.
bool initial_bg = job->is_initially_background();
bool first_proc_internal = job->processes.front()->is_internal();
bool can_use_internal =
!initial_bg && job->processes.size() == 1 && job->processes.front()->is_internal();
bool needs_new_tree = false;
bool needs_new_group = false;
if (!proposed) {
// We don't have a tree yet.
needs_new_tree = true;
// We don't have a group yet.
needs_new_group = true;
} else if (initial_bg) {
// Background jobs always get a new tree.
needs_new_tree = true;
// Background jobs always get a new group.
needs_new_group = true;
} else if (proposed->is_internal() && !can_use_internal) {
// We cannot use the internal tree for this job.
needs_new_tree = true;
// We cannot use the internal group for this job.
needs_new_group = true;
}
job->mut_flags().is_tree_root = needs_new_tree;
job->mut_flags().is_group_root = needs_new_group;
if (!needs_new_tree) {
if (!needs_new_group) {
job->group = proposed;
} else {
properties_t props{};
@ -390,7 +391,7 @@ job_t::~job_t() = default;
void job_t::mark_constructed() {
assert(!is_constructed() && "Job was already constructed");
mut_flags().constructed = true;
if (flags().is_tree_root) {
if (flags().is_group_root) {
group->mark_root_constructed();
}
}

View File

@ -215,9 +215,9 @@ class job_group_t {
void mark_root_constructed() { root_constructed_ = true; };
bool is_root_constructed() const { return root_constructed_; }
/// Given a job and a proposed job group (possibly null), populate the job's tree.
/// The proposed tree is the tree from the parent job, or null if this is a root.
static void populate_tree_for_job(job_t *job, const job_group_ref_t &proposed_tree);
/// Given a job and a proposed job group (possibly null), populate the job's group field.
/// The proposed group is the group from the parent job, or null if this is a root.
static void populate_group_for_job(job_t *job, const job_group_ref_t &proposed_tree);
~job_group_t();
@ -512,8 +512,8 @@ class job_t {
/// Whether to print timing for this job.
bool has_time_prefix{false};
// Indicates that we are the "tree root." Any other jobs using this tree are nested.
bool is_tree_root{false};
// Indicates that we are the "group root." Any other jobs using this tree are nested.
bool is_group_root{false};
} job_flags{};