zsh-workers
 help / color / mirror / code / Atom feed
From: Peter Stephenson <p.w.stephenson@ntlworld.com>
To: zsh-workers@zsh.org
Subject: Re: Possible signal handling issues
Date: Thu, 2 Jan 2014 22:40:31 +0000	[thread overview]
Message-ID: <20140102224031.1f175f26@pws-pc.ntlworld.com> (raw)
In-Reply-To: <20140102215505.323946ce@pws-pc.ntlworld.com>

On Thu, 2 Jan 2014 21:55:05 +0000
Peter Stephenson <p.w.stephenson@ntlworld.com> wrote:
> Consequently, this looks to me like some intrinsic race that happens to
> be particularly reproducible in the "wait" case.

Consider, for example:

sleep 20 &
TRAPINT() { set -x; kill -INT $$; sleep 1 }
wait

Now I get the output from the trap as long as I wait for the sleep to
finish, but the function doesn't exit.  I presume that's because SIGINT
is now arriving while the trap is still running (and the fact that ^C
within a second has no effect is consistent).  Given that traps are
intrinsically asynchronous, that's not necessarily related to a bug in
the shell.  However, it's making the analysis even more complicated.

I further note that if I run sleep 20 normally in the foreground
(without the sleep in the trap) I get:

TRAPINT:0:> kill -INT 25339
TRAPINT:0:> kill -INT 25339

exactly twice.  That was consistent with zsh -i with an fg, but not
setopt monitor with an fg.  I'm guessing (but it's just a guess) that
the first time the trap exits quickly so the INT hits just afterwards
but the second time there's enough processing around that the signal
arrives before the trap has exited (or more precisely before the
internal framing of the trap has finished).

I'm getting less convinced this is anything more than a
you-only-have-yourself-to-blame oddity...

pws


  reply	other threads:[~2014-01-02 22:46 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-12-28 23:02 Bart Schaefer
2014-01-02 21:55 ` Peter Stephenson
2014-01-02 22:40   ` Peter Stephenson [this message]
2014-01-02 22:53     ` Peter Stephenson
2014-01-03  7:52       ` Bart Schaefer
2014-01-03 17:44         ` Peter Stephenson

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20140102224031.1f175f26@pws-pc.ntlworld.com \
    --to=p.w.stephenson@ntlworld.com \
    --cc=zsh-workers@zsh.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/zsh/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).