about summary refs log tree commit diff
path: root/Src/jobs.c
diff options
context:
space:
mode:
authorBart Schaefer <schaefer@zsh.org>2023-12-09 19:36:47 -0800
committerBart Schaefer <schaefer@zsh.org>2023-12-09 19:36:47 -0800
commit0ecc456fb2a4dda75e9910bb019d381406f040e8 (patch)
treec4dd58e4f774a438fa102e4465d8aefa151c4863 /Src/jobs.c
parent618f842b464c090f4a6fb02a9f4d217be9270466 (diff)
downloadzsh-0ecc456fb2a4dda75e9910bb019d381406f040e8.tar.gz
zsh-0ecc456fb2a4dda75e9910bb019d381406f040e8.tar.xz
zsh-0ecc456fb2a4dda75e9910bb019d381406f040e8.zip
52365: record state of exited background jobs so as to be visible in TRAPCHLD
Diffstat (limited to 'Src/jobs.c')
-rw-r--r--Src/jobs.c19
1 files changed, 19 insertions, 0 deletions
diff --git a/Src/jobs.c b/Src/jobs.c
index 4e9767ee4..118c5e61b 100644
--- a/Src/jobs.c
+++ b/Src/jobs.c
@@ -660,6 +660,25 @@ update_job(Job jn)
     }
 }
 
+/**/
+void
+update_bg_job(Job jn, pid_t pid, int status)
+{
+    /*
+     * Accumulate a list of older jobs.  We only do this for
+     * background jobs, which is something in the job table
+     * that's not marked as in the current shell or as shell builtin
+     * and is not equal to the current foreground job.
+     */
+    if (jn && !(jn->stat & (STAT_CURSH|STAT_BUILTIN)) &&
+	jn - jobtab != thisjob) {
+	if (WIFEXITED(status))
+	    addbgstatus(pid, WEXITSTATUS(status));
+	else if (WIFSIGNALED(status))
+	    addbgstatus(pid, 0200 | WTERMSIG(status));
+    }
+}
+
 /* set the previous job to something reasonable */
 
 /**/