Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: localtraps and signal handling on NetBSD
- X-seq: zsh-workers 21262
- From: Peter Stephenson <pws@xxxxxxx>
- To: zsh-workers@xxxxxxxxxx
- Subject: Re: localtraps and signal handling on NetBSD
- Date: Mon, 16 May 2005 11:46:49 +0100
- In-reply-to: <20050514043338.GA82132@xxxxxxxxxxxxxxxxx>
- Mailing-list: contact zsh-workers-help@xxxxxxxxxx; run by ezmlm
- References: <20050425063521.GA17598@xxxxxxxxxxxxxxxxx> <1050425163202.ZM25027@xxxxxxxxxxxxxxxxxxxxxxx> <20050426030308.GA21501@xxxxxxxxxxxxxxxxx> <200504261834.j3QIYHSa018951@xxxxxxxxxxxxxx> <1050427053638.ZM28743@xxxxxxxxxxxxxxxxxxxxxxx> <200504270954.j3R9sujP029445@xxxxxxxxxxxxxx> <20050507171938.GA51740@xxxxxxxxxxxxxxxxx> <5415.1115631148@xxxxxxx> <20050510184600.GA67763@xxxxxxxxxxxxxxxxx> <200505131127.j4DBR0Yt014380@xxxxxxxxxxxxxx> <20050514043338.GA82132@xxxxxxxxxxxxxxxxx>
Vincent Stemen wrote:
> # --------- <test script> -----------
> sigterm1()
> {
> trap 'echo "-- sigterm2 --"' TERM
> echo "sigterm1(): sending SIGTERM"
> kill -TERM $$
> trap sigterm1 TERM
> sleep 1
> }
>
> trap sigterm1 TERM
>
> echo
> echo "main: sending SIGTERM"
> kill -TERM $$
> echo "main: sending SIGTERM"
> kill -TERM $$
> # --------- </test script> -----------
>
> Here is the output of zsh and bash.
>
> <zsh>
> main: sending SIGTERM
> sigterm1(): sending SIGTERM
> sigterm1(): sending SIGTERM
> sigterm1(): sending SIGTERM
> sigterm1(): sending SIGTERM
> ... continues forever
> </zsh>
Yes, I can see this, but this isn't the same example I was looking at
when I saw different behaviour from you.
What I think is happening here is that signals *are* being queued. Then
the SIGTERM is delivered after sigterm1 has returned, at which point
sigterm1 has been reinstalled as the signal handler, so gets called
again ad infinitum.
In this case bash and zsh are actually trying a bit harder to do the
right thing, at least as far as safety of the execution environment is
concerned. Not queueing signals can cause significant reentrancy
problems. However, it may be possible to unqueue signals temporarily at
some point. That's still not trivial; the code's currently not written
to allow that, since as I said before the queue/unqueues are all nested
and you need to have some clue about the environment to decide whether
temporarily unqueuing is safe. Possibly some queue/unqueue pair can be
moved deeper into the code, leaving some points at which signals will be
handled, but that's not trivial either.
--
Peter Stephenson <pws@xxxxxxx> Software Engineer
CSR PLC, Churchill House, Cambridge Business Park, Cowley Road
Cambridge, CB4 0WZ, UK Tel: +44 (0)1223 692070
**********************************************************************
This email and any files transmitted with it are confidential and
intended solely for the use of the individual or entity to whom they
are addressed. If you have received this email in error please notify
the system manager.
**********************************************************************
Messages sorted by:
Reverse Date,
Date,
Thread,
Author