From 1823f5d95f69b4da88ec4402c6fc371718f59bae Mon Sep 17 00:00:00 2001 From: ridiculousfish Date: Sun, 26 Jul 2020 16:51:11 -0700 Subject: [PATCH] Remove the send_sigcont from continue_job We can just send sigcont if the job is stopped; no need to make this an explicit param. --- src/builtin_bg.cpp | 2 +- src/builtin_fg.cpp | 2 +- src/exec.cpp | 2 +- src/proc.cpp | 5 ++++- src/proc.h | 10 ++++------ 5 files changed, 11 insertions(+), 10 deletions(-) diff --git a/src/builtin_bg.cpp b/src/builtin_bg.cpp index 9e376521e..fdde21c29 100644 --- a/src/builtin_bg.cpp +++ b/src/builtin_bg.cpp @@ -32,7 +32,7 @@ static int send_to_bg(parser_t &parser, io_streams_t &streams, job_t *j) { j->command_wcstr()); parser.job_promote(j); j->group->set_is_foreground(false); - j->continue_job(parser, true, j->is_stopped()); + j->continue_job(parser, true); return STATUS_CMD_OK; } diff --git a/src/builtin_fg.cpp b/src/builtin_fg.cpp index 137c1300a..314becb10 100644 --- a/src/builtin_fg.cpp +++ b/src/builtin_fg.cpp @@ -107,6 +107,6 @@ int builtin_fg(parser_t &parser, io_streams_t &streams, wchar_t **argv) { parser.job_promote(job); job->group->set_is_foreground(true); - job->continue_job(parser, true, job->is_stopped()); + job->continue_job(parser, true); return STATUS_CMD_OK; } diff --git a/src/exec.cpp b/src/exec.cpp index 36d7fc2b0..3b65b4fe4 100644 --- a/src/exec.cpp +++ b/src/exec.cpp @@ -1003,7 +1003,7 @@ bool exec_job(parser_t &parser, const shared_ptr &j, const io_chain_t &bl return false; } - j->continue_job(parser, reclaim_foreground_pgrp, false); + j->continue_job(parser, reclaim_foreground_pgrp); return true; } diff --git a/src/proc.cpp b/src/proc.cpp index 9ab2ceb43..06dc8ba53 100644 --- a/src/proc.cpp +++ b/src/proc.cpp @@ -896,7 +896,7 @@ maybe_t job_t::get_pgid() const { return group->get_pgid(); } job_id_t job_t::job_id() const { return group->get_id(); } -void job_t::continue_job(parser_t &parser, bool reclaim_foreground_pgrp, bool send_sigcont) { +void job_t::continue_job(parser_t &parser, bool reclaim_foreground_pgrp) { // Put job first in the job list. parser.job_promote(this); mut_flags().notified = false; @@ -904,6 +904,9 @@ void job_t::continue_job(parser_t &parser, bool reclaim_foreground_pgrp, bool se int pgid = -2; if (auto tmp = get_pgid()) pgid = *tmp; + // We must send_sigcont if the job is stopped. + bool send_sigcont = this->is_stopped(); + FLOGF(proc_job_run, L"%ls job %d, gid %d (%ls), %ls, %ls", send_sigcont ? L"Continue" : L"Start", job_id(), pgid, command_wcstr(), is_completed() ? L"COMPLETED" : L"UNCOMPLETED", diff --git a/src/proc.h b/src/proc.h index f9ce8d50b..89a65ea34 100644 --- a/src/proc.h +++ b/src/proc.h @@ -454,14 +454,12 @@ class job_t { /// \return whether this job and its parent chain are fully constructed. bool job_chain_is_fully_constructed() const; - /// Resume a (possibly) stopped job. Puts job in the foreground. If cont is true, restore the - /// saved terminal modes and send the process group a SIGCONT signal to wake it up before we - /// block. + /// Continues running a job, which may be stopped, or may just have started. + /// This will send SIGCONT if the job is stopped. /// /// \param reclaim_foreground_pgrp whether, when the job finishes or stops, to reclaim the - /// foreground pgrp (via tcsetpgrp). \param send_sigcont Whether SIGCONT should be sent to the - /// job if it is in the foreground. - void continue_job(parser_t &parser, bool reclaim_foreground_pgrp, bool send_sigcont); + /// foreground pgrp (via tcsetpgrp). + void continue_job(parser_t &parser, bool reclaim_foreground_pgrp); /// Send the specified signal to all processes in this job. /// \return true on success, false on failure.