zsh-workers
 help / color / mirror / code / Atom feed
From: Vincent Stemen <zsh@hightek.org>
To: Zsh hackers list <zsh-workers@sunsite.dk>
Subject: Re: PATCH: (2) Re: FreeBSD compatability feature request
Date: Thu, 22 Apr 2004 03:59:56 -0500	[thread overview]
Message-ID: <20040422085956.GA69814@quark.hightek.org> (raw)
In-Reply-To: <18144.1082545500@csr.com>

On Wed, Apr 21, 2004 at 12:05:00PM +0100, Peter Stephenson wrote:
> OK, plan B.
> 
> I am now frightened about what happens when any signals are blocked
> while we are waiting for a child.  So instead of doing that, I propose
> queuing traps separately from signals.  This can't cause any races,
> since no extra signal or process handling is involved.  The code is a
> bit more verbose, but should be much safer.  This patches on top of the
> other one.
> 
> Again, this should be exactly equivalent to 4.2.0 unless TRAPS_ASYNC is
> unset (POSIX compatibility mode).
> 
> This ought to fix the hang.

Hi Peter.

I applied the patch.  It definitely fixed the hanging problem.  I can
now plug it in place of /bin/sh on FreeBSD and all the init scripts
seem to run properly without errors when booting the system.

However, I actually tested the signal handling this time and, unless I
am not understanding the trapsasync mode enough to test properly, I
don't think it is working.  If I understand it correctly, with "set -T"
shouldn't the parent process immediately get any signals it has trapped
even if a child process it is waiting on has disabled the signals?

With that in mind, I tested it with two scripts, sigtrap and sigblock.

quark # cat sigtrap

echo "sigtrap: trapping SIGINT and calling sigblock"
set -T
trap 'echo Got signal. Exiting.; exit' 2
./sigblock
echo "sigtrap: Exiting normally"


quark # cat sigblock

echo "sigblock: blocking SIGINT and sleeping"
trap '' 2
sleep 5


quark # ./sh sigtrap
sigtrap: trapping SIGINT and calling sigblock
sigblock: blocking SIGINT and sleeping
^C^Csigblock: exiting
Got signal. Exiting.
quark #


After hitting <cntl>c, it completed the 5 second delay before printing
"sigblock: exiting".  It behaved the same whether I had the "set -T" in
the script or not.  I was expecting sigtrap to immediately print "Got
signal. Exiting." when I hit <cntl>c with trapsasync set.

Be aware if you test this under Linux that Linux, at least as of the
2.4.x kernels about a year ago the last time I tested it, does not pass
signals on to the parent process like FreeBSD does.  So you may not see
the "Got signal" message from the parent sigtrap process.  In the past,
I always had to check for a 130 return code from every child process
(which was a pain) to know if the user hit <cntl>c so I can call my
signal handling routine.  I was not able to have dependable signal traps
in my scripts because you could not always depend on the child returning
130 when it got interrupted.

-- 
Vincent Stemen
Avoid the VeriSign/Network Solutions domain registration trap!
Read how Network Solutions (NSI) was involved in stealing our domain name.
http://www.InetAddresses.net


  reply	other threads:[~2004-04-22  9:00 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <20040417222222.GA27230@quark.hightek.org>
     [not found] ` <21533.1082374109@csr.com>
2004-04-21  8:21   ` Vincent Stemen
2004-04-21 10:00     ` Peter Stephenson
2004-04-21 11:05     ` PATCH: (2) " Peter Stephenson
2004-04-22  8:59       ` Vincent Stemen [this message]
2004-04-22  9:59         ` Peter Stephenson
2004-04-22 10:17           ` Peter Stephenson
2004-04-22 16:09             ` Jos Backus
2004-04-23  5:30               ` Vincent Stemen
2004-04-23  9:56                 ` Peter Stephenson
2004-04-27  3:56             ` Bart Schaefer
2004-04-27  9:58               ` Peter Stephenson
2004-04-29  2:16                 ` Vincent Stemen
2004-04-30 21:26         ` PATCH: (3) " Peter Stephenson
2004-05-01  1:45           ` Vincent Stemen
2004-05-01  2:23             ` Vincent Stemen
2004-05-04  7:17           ` PATCH: (3) - FreeBSD compatability issue resolved Vincent Stemen
2004-05-04  9:28             ` 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=20040422085956.GA69814@quark.hightek.org \
    --to=zsh@hightek.org \
    --cc=zsh-workers@sunsite.dk \
    /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).