Add a property describing when a job is initially backgrounded

Track separately whether a job is in the background now, and whether
it was constructed in the background via the & syntax.
This commit is contained in:
ridiculousfish
2020-02-19 10:21:09 -07:00
parent 123f3e6f93
commit a4b66d948b
3 changed files with 13 additions and 3 deletions

View File

@@ -1255,6 +1255,7 @@ end_execution_reason_t parse_execution_context_t::run_1_job(tnode_t<g::job> job_
job_t::properties_t props{};
props.wants_terminal = wants_job_control && !ld.is_event;
props.initial_background = job_node_is_background(job_node);
props.skip_notification =
ld.is_subshell || ld.is_block || ld.is_event || !parser->is_interactive();
props.from_event_handler = ld.is_event;
@@ -1263,7 +1264,7 @@ end_execution_reason_t parse_execution_context_t::run_1_job(tnode_t<g::job> job_
shared_ptr<job_t> job = std::make_shared<job_t>(props);
job->tmodes = tmodes;
job->mut_flags().foreground = !job_node_is_background(job_node);
job->mut_flags().foreground = !props.initial_background;
// We are about to populate a job. One possible argument to the job is a command substitution
// which may be interested in the job that's populating it, via '--on-job-exit caller'. Record