Prevent disown from directly removing jobs

This prevents the `disown` builtin from directly removing jobs out of
the jobs list to prevent sanity issues, as `disown` may be called within
the context of a subjob (e.g. in a function or block) in which case the
parent job might not yet be done with the reference to the child job.

Instead, a flag is set and the parser removes the job from the list only
after the entire execution chain has completed.

Closes #5720.
This commit is contained in:
Mahmoud Al-Qudsi
2019-04-09 23:29:58 -05:00
parent f1b261388a
commit 394623bf08
4 changed files with 20 additions and 13 deletions

View File

@@ -1269,6 +1269,11 @@ parse_execution_result_t parse_execution_context_t::run_1_job(tnode_t<g::job> jo
remove_job(job.get());
}
// This job was disowned during its own execution or the execution of its subjobs
if (job->get_flag(job_flag_t::PENDING_REMOVAL)) {
remove_job(job.get());
}
// Only external commands require a new fishd barrier.
if (job_contained_external_command) {
set_proc_had_barrier(false);