diff --git a/src/proc.cpp b/src/proc.cpp index fa65e66ed..e2674d946 100644 --- a/src/proc.cpp +++ b/src/proc.cpp @@ -536,10 +536,10 @@ static void remove_disowned_jobs(job_list_t &jobs) { /// \return true if we printed a status message, false if not. static bool try_clean_process_in_job(parser_t &parser, process_t *p, job_t *j, std::vector *exit_events) { - if (!p->completed || !p->pid) { + if (p->marked_exit_event || !p->completed || !p->pid) { return false; } - + p->marked_exit_event = true; auto s = p->status; // Add an exit event if the process did not come from a job handler. @@ -573,9 +573,6 @@ static bool try_clean_process_in_job(parser_t &parser, process_t *p, job_t *j, args.push_back(p->argv0()); } call_job_summary(parser, args); - // Clear status so it is not reported more than once. - // TODO: this seems like a clumsy way to ensure that. - p->status = proc_status_t::from_exit_code(0); return true; } diff --git a/src/proc.h b/src/proc.h index cb0fe0894..f2cc1066f 100644 --- a/src/proc.h +++ b/src/proc.h @@ -278,6 +278,9 @@ class process_t : noncopyable_t { /// True if process has stopped. bool stopped{false}; + /// Set once we have generated (or decided not to generate) a process_exit event. + bool marked_exit_event{false}; + /// Reported status value. proc_status_t status{};