diff --git a/src/exec.cpp b/src/exec.cpp index 3ef1288ab..0b6e23593 100644 --- a/src/exec.cpp +++ b/src/exec.cpp @@ -714,13 +714,6 @@ static proc_performer_t get_performer_for_process(process_t *p, job_t *job, }; } else { assert(p->type == process_type_t::function); - // If this function is the only process in the current job - // and that job is in the foreground then mark this job as internal - // so it doesn't increment the job id for any jobs created within this - // function. - if (p->is_first_in_job && p->is_last_in_job && job->flags().foreground) { - job->mark_internal(); - } auto props = function_get_properties(p->argv0()); if (!props) { FLOGF(error, _(L"Unknown function '%ls'"), p->argv0()); @@ -771,6 +764,14 @@ static bool exec_block_or_func_process(parser_t &parser, const std::shared_ptris_first_in_job && p->is_last_in_job && j->flags().foreground) { + j->mark_internal(); + } + // Get the process performer, and just execute it directly. // Do it in this scoped way so that the performer function can be eagerly deallocating releasing // its captured io chain. diff --git a/tests/checks/job_ids.fish b/tests/checks/job_ids.fish index df4d8a16a..ccf761131 100644 --- a/tests/checks/job_ids.fish +++ b/tests/checks/job_ids.fish @@ -10,16 +10,15 @@ function func100 sleep 100 & set -g tokill $tokill $last_pid end +func100 -function func200 +# The redirection ensures this becomes a real job. +begin sleep 200 & set -g tokill $tokill $last_pid -end +end