Fix up --on-job-exit caller

The `function --on-job-exit caller` feature allows a command substitution
to observe when the parent job exits. This has never worked very well - in
particular it is based on job IDs, so a function that observes this will
run multiple times. Implement it properly.

Do this by having a not-recycled "internal job id".

This is only used by psub, but ensure it works properly none-the-less.
This commit is contained in:
ridiculousfish
2020-02-08 15:43:21 -08:00
parent 93fc0d06d4
commit 6bf9ae9aeb
8 changed files with 65 additions and 19 deletions

View File

@@ -148,9 +148,9 @@ struct library_data_t {
/// Whether we are currently cleaning processes.
bool is_cleaning_procs{false};
/// The job id of the job being populated.
/// The internal job id of the job being populated, or 0 if none.
/// This supports the '--on-job-exit caller' feature.
job_id_t caller_job_id{-1};
internal_job_id_t caller_id{0};
/// Whether we are running a subshell command.
bool is_subshell{false};