From 91df645c62a0a09193046b71ab6bea444b57ea8c Mon Sep 17 00:00:00 2001 From: ridiculousfish Date: Sat, 8 Feb 2020 14:14:21 -0800 Subject: [PATCH] Make job_control a constant property of job_t It no longer changes. --- src/exec.cpp | 6 ------ src/parse_execution.cpp | 2 +- src/proc.h | 8 ++++---- 3 files changed, 5 insertions(+), 11 deletions(-) diff --git a/src/exec.cpp b/src/exec.cpp index 4d6914810..e5e74cad7 100644 --- a/src/exec.cpp +++ b/src/exec.cpp @@ -918,12 +918,6 @@ bool exec_job(parser_t &parser, const shared_ptr &j, const job_lineage_t // Check to see if we should reclaim the foreground pgrp after the job finishes or stops. const bool reclaim_foreground_pgrp = (tcgetpgrp(STDIN_FILENO) == pgrp); - // If we are running nested inside a function or block with job control, then we need job - // control too. - if (lineage.root_has_job_control) { - j->mut_flags().job_control = true; - } - // Perhaps we know our pgroup already. assert(j->pgid == INVALID_PID && "Should not yet have a pid."); switch (j->pgroup_provenance) { diff --git a/src/parse_execution.cpp b/src/parse_execution.cpp index d4594c9d4..2bdec06a2 100644 --- a/src/parse_execution.cpp +++ b/src/parse_execution.cpp @@ -1273,12 +1273,12 @@ end_execution_reason_t parse_execution_context_t::run_1_job(tnode_t job_ props.skip_notification = ld.is_subshell || ld.is_block || ld.is_event || !parser->is_interactive(); props.from_event_handler = ld.is_event; + props.job_control = wants_job_control; shared_ptr job = std::make_shared(acquire_job_id(), props, this->lineage); job->tmodes = tmodes; job->mut_flags().foreground = !job_node_is_background(job_node); - job->mut_flags().job_control = wants_job_control; // We are about to populate a job. One possible argument to the job is a command substitution // which may be interested in the job that's populating it, via '--on-job-exit caller'. Record diff --git a/src/proc.h b/src/proc.h index 0cc0df325..7cd54db43 100644 --- a/src/proc.h +++ b/src/proc.h @@ -329,6 +329,9 @@ class job_t { /// Whether this job was created as part of an event handler. bool from_event_handler{}; + + /// Whether the job is under job control, i.e. has its own pgrp. + bool job_control{}; }; private: @@ -443,9 +446,6 @@ class job_t { /// Whether the exit status should be negated. This flag can only be set by the not builtin. bool negate{false}; - /// Whether the job is under job control, i.e. has its own pgrp. - bool job_control{false}; - /// This job is disowned, and should be removed from the active jobs list. bool disown_requested{false}; @@ -460,7 +460,7 @@ class job_t { flags_t &mut_flags() { return job_flags; } /// \return if we want job control. - bool wants_job_control() const { return flags().job_control; } + bool wants_job_control() const { return properties.job_control; } /// \return if this job should own the terminal when it runs. bool should_claim_terminal() const { return properties.wants_terminal && is_foreground(); }