Bravely do not report completed jobs as stopped

Prior to this change, job_t::is_stopped() returned true if there were
zero running processes in the job. This meant that completed jobs were
reported as stopped. Stop doing this, it's a footgun.
This commit is contained in:
ridiculousfish 2021-11-03 12:23:25 -07:00
parent 9b1e04dba2
commit 00a1df3811

View file

@ -96,17 +96,20 @@ void set_job_control_mode(job_control_t mode) {
void proc_init() { signal_set_handlers_once(false); }
/// Return true if all processes in the job have stopped or completed.
/// Return true if all processes in the job are stopped or completed, and there is at least one
/// stopped process.
bool job_t::is_stopped() const {
bool has_stopped = false;
for (const process_ptr_t &p : processes) {
if (!p->completed && !p->stopped) {
return false;
}
has_stopped |= p->stopped;
}
return true;
return has_stopped;
}
/// Return true if the last processes in the job has completed.
/// Return true if all processes in the job have completed.
bool job_t::is_completed() const {
assert(!processes.empty());
for (const process_ptr_t &p : processes) {