From: "Kevin B. Hendricks" <kevin.hendricks@sympatico.ca>
To: "David A. Gatwood" <dgatwood@deepspace.mklinux.org>
Cc: linuxppc-dev@lists.linuxppc.org
Subject: Re: Another signal handling bug?
Date: Thu, 17 Aug 2000 18:28:31 -0400 [thread overview]
Message-ID: <399C670F.912463EE@sympatico.ca> (raw)
In-Reply-To: Pine.LNX.3.96.1000817190341.8005C-100000@deepspace.mklinux.org
Hi David,
Two things:
1. setting the sa_mask to sigemptyset will not mask out any signals in your
handler (see the sigaction man page). I think you want sigfillset if you want
to mask all signals while in your handler. Here is a snippet from the sigaction
man page.
sa_mask gives a mask of signals which should be blocked
during execution of the signal handler. In addition, the
signal which triggered the handler will be blocked, unless
the SA_NODEFER or SA_NOMASK flags are used.
2. You should techically always be calling async signal safe routines
frominside any signal handlers. Grabbing a mutex lock is not one of these. You
can sometimes work around this using semaphore posts (which are technically
allowed) inside signal handlers since they are async signal safe.
Hope this helps.
Kevin
.
"David A. Gatwood" wrote:
>
> On Wed, 16 Aug 2000, David A. Gatwood wrote:
>
> > > > I've just noticed something that, unless I've really misunderstood the man
> > > > page, is another significant bug in signal handling. Put simply, despite
> > > > configuration to the contrary, signals are not being blocked during their
> > > > handlers, i.e. I'm getting nested signal handlers that never return.
> > > >
> > > > The code in question basically does this:
> > > >
> > > > sa.sa_handler = alarm_handler;
> > > > sigemptyset(&sa.sa_mask);
> > > > sa.sa_flags = 0;
> > > > sigaction(SIGALRM, &sa, NULL);
>
> Well, I know why the one handler didn't return -- there was the nasty
> little point of it trying to take a lock twice. After fixing that, the
> signal handler _happens_ to always return before the next signal gets
> delivered. However, obviously that doesn't solve the real issue, since
> any heavy system load could cause that "luck" to no longer hold true.
> Fortunately, for my code's purposes, that is good enough, as long as the
> pthreads locks are correct, but it's still somewhat scary. :-)
>
> Ideas?
> David
>
> ---------------------------------------------------------------------
> A brief Haiku:
>
> Microsoft is bad.
> It seems secure at first glance.
> Then you read your mail.
>
** Sent via the linuxppc-dev mail list. See http://lists.linuxppc.org/
next prev parent reply other threads:[~2000-08-17 22:28 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2000-08-17 5:44 Another signal handling bug? David A. Gatwood
2000-08-17 6:15 ` David A. Gatwood
2000-08-17 6:26 ` David A. Gatwood
2000-08-18 2:08 ` David A. Gatwood
2000-08-17 22:28 ` Kevin B. Hendricks [this message]
2000-08-18 2:46 ` David A. Gatwood
2000-08-17 23:03 ` Kevin B. Hendricks
2000-08-18 3:26 ` David A. Gatwood
2000-08-17 23:07 ` Kevin B. Hendricks
2000-08-18 3:28 ` David A. Gatwood
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=399C670F.912463EE@sympatico.ca \
--to=kevin.hendricks@sympatico.ca \
--cc=dgatwood@deepspace.mklinux.org \
--cc=khendricks@ivey.uwo.ca \
--cc=linuxppc-dev@lists.linuxppc.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.
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).