7 Bug-Reported-by: Steven Pelley <stevenpelley@gmail.com>
8 Bug-Reference-ID: <CAGOYURh6CKaE-D0Z8puP-tQknavCQNRHo02vpvgMQqaTG3_cRw@mail.gmail.com>
9 Bug-Reference-URL: https://lists.gnu.org/archive/html/bug-bash/2024-01/msg00104.html
13 `wait -n' can fail to return some jobs if they exit due to signals the shell
14 does not report to the user.
16 Patch (apply with `patch -p0'):
18 *** ../bash-5.2-patched/jobs.c Thu Nov 9 14:59:14 2023
19 --- jobs.c Tue Jul 30 15:27:44 2024
22 ((DEADJOB (job) && IS_FOREGROUND (job) == 0) || STOPPED (job)))
25 /* If job control is disabled, don't print the status messages.
26 Mark dead jobs as notified so that they get cleaned up. If
28 ((DEADJOB (job) && IS_FOREGROUND (job) == 0) || STOPPED (job)))
31 ! /* Do the same thing and don't print anything or mark as notified
32 ! for the signals we're not going to report on. This is the opposite
33 ! of the first two cases under case JDEAD below. */
34 ! else if (interactive_shell == 0 && DEADJOB (job) && IS_FOREGROUND (job) == 0 &&
35 ! WIFSIGNALED (s) && (termsig == SIGINT
36 ! #if defined (DONT_REPORT_SIGTERM)
37 ! || termsig == SIGTERM
39 ! #if defined (DONT_REPORT_SIGPIPE)
40 ! || termsig == SIGPIPE
42 ! || signal_is_trapped (termsig)))
45 ! /* hang onto the status if the shell is running -c command */
46 ! else if (startup_state == 2 && subshell_environment == 0 &&
47 ! WIFSIGNALED (s) == 0 &&
48 ! ((DEADJOB (job) && IS_FOREGROUND (job) == 0) || STOPPED (job)))
51 /* If job control is disabled, don't print the status messages.
52 Mark dead jobs as notified so that they get cleaned up. If
55 /* Print info on jobs that are running in the background,
56 and on foreground jobs that were killed by anything
57 ! except SIGINT (and possibly SIGPIPE). */
58 switch (JOBSTATE (job))
61 /* Print info on jobs that are running in the background,
62 and on foreground jobs that were killed by anything
63 ! except SIGINT (and possibly SIGTERM and SIGPIPE). */
64 switch (JOBSTATE (job))
69 else if (IS_FOREGROUND (job))
71 + /* foreground jobs, interactive and non-interactive shells */
72 #if !defined (DONT_REPORT_SIGPIPE)
73 if (termsig && WIFSIGNALED (s) && termsig != SIGINT)
76 fprintf (stderr, "\n");
79 ! else if (job_control) /* XXX job control test added */
82 dir = current_working_directory ();
84 fprintf (stderr, "\n");
86 + /* foreground jobs that exit cleanly */
87 + jobs[job]->flags |= J_NOTIFIED;
89 ! else if (job_control)
91 + /* background jobs with job control, interactive and
92 + non-interactive shells */
94 dir = current_working_directory ();
99 ! jobs[job]->flags |= J_NOTIFIED;
105 ! /* Interactive shells without job control enabled are handled
107 ! /* XXX - this is a catch-all in case we missed a state */
110 ! internal_debug("notify_of_job_status: catch-all setting J_NOTIFIED on job %d (%d), startup state = %d", job, jobs[job]->flags, startup_state);
111 ! jobs[job]->flags |= J_NOTIFIED;
116 *** ../bash-5.2/patchlevel.h 2020-06-22 14:51:03.000000000 -0400
117 --- patchlevel.h 2020-10-01 11:01:28.000000000 -0400
120 looks for to find the patch level (for the sccs version string). */
122 ! #define PATCHLEVEL 29
124 #endif /* _PATCHLEVEL_H_ */
126 looks for to find the patch level (for the sccs version string). */
128 ! #define PATCHLEVEL 30
130 #endif /* _PATCHLEVEL_H_ */