Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Re: Bug with traps and exit



On Mon, 2019-12-16 at 05:24 +0000, Daniel Shahaf wrote:
> > trap 'printf $1; exit; printf $2' USR1
> > fn() {
> >         printf 1
> >         kill -s usr1 $$
> >         printf 2
> > }
> > printf 0
> > fn A B
> > printf 3
> Here, Martijn was saying that zsh should print 01A but in fact prints 01A2.
> This suggests the 'exit' inhibits «printf $2» and «printf 3» from running, but
> doesn't inhibit «printf 2» (without a dollar sign) from running.  How would
> you approach something like this?  I'm guessing bin_exit should set a global
> volatile int variable to '1' if it's called from a signal handler, but where
> would that variable be checked?

Looks like Bart's already come up with the major gotchas in this case
--- there are some deliberate delays in handling around exiting and this
might well interact badly with an asynchronous signal.

pws



Messages sorted by: Reverse Date, Date, Thread, Author