Clean up job flags, status helpers, and instance helper methods

* Convert JOB_* enums to scoped enums
* Convert standalone job_is_* functions to member functions
* Convert standalone job_{promote, signal, continue} to member functions
* Convert standolen job_get{,_from_pid} to `job_t` static functions
* Reduce usage of JOB_* enums outside of proc.cpp by using new
  `job_t::is_foo()` const helper methods instead.

This patch is only a refactor and should not change any functionality or
behavior (both observed and unobserved).
This commit is contained in:
Mahmoud Al-Qudsi
2018-10-02 12:30:23 -05:00
parent e753581df7
commit f9118d964e
14 changed files with 196 additions and 191 deletions

View File

@@ -772,7 +772,7 @@ parse_execution_result_t parse_execution_context_t::populate_plain_process(
bool have_bg = false;
const job_t *bg = nullptr;
while ((bg = jobs.next())) {
if (!job_is_completed(bg)) {
if (!bg->is_completed()) {
have_bg = true;
break;
}
@@ -975,7 +975,7 @@ bool parse_execution_context_t::determine_io_chain(tnode_t<g::arguments_or_redir
parse_execution_result_t parse_execution_context_t::populate_not_process(
job_t *job, process_t *proc, tnode_t<g::not_statement> not_statement) {
job->set_flag(JOB_NEGATE, !job->get_flag(JOB_NEGATE));
job->set_flag(job_flag_t::NEGATE, !job->get_flag(job_flag_t::NEGATE));
return this->populate_job_process(job, proc,
not_statement.require_get_child<g::statement, 1>());
}
@@ -1184,15 +1184,15 @@ parse_execution_result_t parse_execution_context_t::run_1_job(tnode_t<g::job> jo
shared_ptr<job_t> job = std::make_shared<job_t>(acquire_job_id(), block_io);
job->tmodes = tmodes;
job->set_flag(JOB_CONTROL,
job->set_flag(job_flag_t::JOB_CONTROL,
(job_control_mode == JOB_CONTROL_ALL) ||
((job_control_mode == JOB_CONTROL_INTERACTIVE) && shell_is_interactive()));
job->set_flag(JOB_FOREGROUND, !job_node_is_background(job_node));
job->set_flag(job_flag_t::FOREGROUND, !job_node_is_background(job_node));
job->set_flag(JOB_TERMINAL, job->get_flag(JOB_CONTROL) && !is_event);
job->set_flag(job_flag_t::TERMINAL, job->get_flag(job_flag_t::JOB_CONTROL) && !is_event);
job->set_flag(JOB_SKIP_NOTIFICATION,
job->set_flag(job_flag_t::SKIP_NOTIFICATION,
is_subshell || is_block || is_event || !shell_is_interactive());
// Tell the current block what its job is. This has to happen before we populate it (#1394).