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

@@ -2242,7 +2242,7 @@ void reader_bg_job_warning() {
job_iterator_t jobs;
while (job_t *j = jobs.next()) {
if (!job_is_completed(j)) {
if (!j->is_completed()) {
fwprintf(stdout, L"%6d %ls\n", j->processes[0]->pid, j->command_wcstr());
}
}
@@ -2254,9 +2254,9 @@ void reader_bg_job_warning() {
void kill_background_jobs() {
job_iterator_t jobs;
while (job_t *j = jobs.next()) {
if (!job_is_completed(j)) {
if (job_is_stopped(j)) job_signal(j, SIGCONT);
job_signal(j, SIGHUP);
if (!j->is_completed()) {
if (j->is_stopped()) j->signal(SIGCONT);
j->signal(SIGHUP);
}
}
}
@@ -2277,7 +2277,7 @@ static void handle_end_loop() {
bool bg_jobs = false;
job_iterator_t jobs;
while (const job_t *j = jobs.next()) {
if (!job_is_completed(j)) {
if (!j->is_completed()) {
bg_jobs = true;
break;
}