bug-bash
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [PATCH] Fix foreground dead jobs in trap handlers reported like back


From: Chet Ramey
Subject: Re: [PATCH] Fix foreground dead jobs in trap handlers reported like background ones in `jobs'
Date: Fri, 30 Sep 2022 15:30:09 -0400
User-agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:102.0) Gecko/20100101 Thunderbird/102.3.0

On 7/17/22 11:52 PM, Koichi Murase wrote:

Bash Version: 5.1.4, also in the current devel 87a6e89e

Description:

   In interactive shells, the foreground dead jobs (i.e., foreground
   jobs that have already terminated) in trap handlers, commands called
   through `bind -x', and `PROMPT_COMMAND' (let us call these three
   contexts as the affected context. Note: There might be even other
   similar contexts) are treated as if they are the background dead
   jobs.  This causes several unintended behaviors: (1) When `jobs' is
   called in the affected contexts, all the foreground jobs that have
   already terminated in the same call of the affected contexts are
   printed.  (2) When `wait -n' is called in the affected contexts, it
   immediately returns with the exit status of the previous foreground
   dead job.

   These behaviors are different from those in the normal case where
   `jobs' and `wait -n' are executed outside the trap handler, and I do
   not see the reasoning for this behavior difference between inside
   and outside of the affected contexts.  I hope the behavior in the
   affected contexts would be similar to that in the normal contexts
   where the foreground dead job information is not printed.

Thanks for the detailed report and suggested patches. I applied a variant
of your patch 3; the change to print_job appears not to be needed (at least
all of your test cases work without it).

Chet

--
``The lyf so short, the craft so long to lerne.'' - Chaucer
                 ``Ars longa, vita brevis'' - Hippocrates
Chet Ramey, UTech, CWRU    chet@case.edu    http://tiswww.cwru.edu/~chet/




reply via email to

[Prev in Thread] Current Thread [Next in Thread]