From: "Peter M. Jansson" <petej@clickvision.com>
To: linuxppc-dev@lists.linuxppc.org
Subject: SIGALRM can't be delivered after longjmp from handler?
Date: Wed, 15 Mar 2000 13:41:29 -0500 [thread overview]
Message-ID: <38CFD959.52E9F85@clickvision.com> (raw)
I wrote the example that follows to illustrate what I think is a
problem with signal delivery. If this program works, then it should run
in 5 cycles; the first 2 end with the "Timed out" message, while the
last 3 end with the "Wait interrupted" message. On my PowerMac 7200
running 2.2.15pre3, I get 2 "Timed out" cycles, one "Wait interrupted"
cycle, and then two more "Timed out" cycles. What I think is going on
is that, once the SIGALRM handler executes the longjmp, no further
SIGALRM signals are delivered to the process -- I don't know if this is
because the signals aren't delivered, or because the setitimer call
isn't working. I've observed this example to run correctly on BSD/OS,
IRIX, and Solaris, and seen it fail on LinuxPPC and Linux x86.
Anyone seen this, and possibly know of a fix or workaround?
Pete.
-------------------------------
#include <signal.h>
#include <setjmp.h>
#include <sys/time.h>
#include <stdio.h>
static jmp_buf env;
static unsigned int count = 0;
static void
interrupt()
{
printf ("Interrupt: %d\n", count);
if (count > 2)
longjmp(env, 1);
}
main ()
{
struct timeval tv;
struct itimerval it, oit;
while (count++ < 5) {
printf("Cycle %d\n", count);
if (setjmp(env)) {
printf ("Wait interrupted\n");
} else {
if (signal(SIGALRM, interrupt) == SIG_ERR)
perror("signal");
getitimer(ITIMER_REAL, &oit);
timerclear(&it.it_interval);
it.it_value.tv_sec = 2;
it.it_value.tv_usec = 16665;
if (setitimer(ITIMER_REAL, &it, &oit) < 0)
perror("tick");
printf ("Set timer; waiting...\n");
tv.tv_sec = 5;
tv.tv_usec = 0;
select(0, NULL, NULL, NULL, &tv);
printf ("Timed out\n");
}
}
}
** Sent via the linuxppc-dev mail list. See http://lists.linuxppc.org/
next reply other threads:[~2000-03-15 18:41 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2000-03-15 18:41 Peter M. Jansson [this message]
2000-03-16 1:47 ` SIGALRM can't be delivered after longjmp from handler? Sriranga Veeraraghavan
2000-03-16 1:50 ` Peter M. Jansson
2000-03-16 1:57 ` David A. Gatwood
2000-03-16 1:55 ` Peter M. Jansson
2000-03-16 2:10 ` David A. Gatwood
2000-03-16 2:07 ` Peter M. Jansson
2000-03-16 2:25 ` David A. Gatwood
2000-03-16 2:18 ` Peter M. Jansson
-- strict thread matches above, loose matches on Subject: below --
2000-03-16 9:35 D.J. Barrow
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=38CFD959.52E9F85@clickvision.com \
--to=petej@clickvision.com \
--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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.