This is the mail archive of the
cygwin
mailing list for the Cygwin project.
2nd occurrence of signal not being handled?
- From: Mark Geisert <mark at maxrnd dot com>
- To: cygwin at cygwin dot com
- Date: Sat, 19 Dec 2009 05:23:42 +0000 (UTC)
- Subject: 2nd occurrence of signal not being handled?
I'm trying to get a larger application working but have an issue with signal
handling. I've boiled the issue down to the STC below. It causes two access
violations, only the first of which gets handled by the SIGSEGV signal handler
I've registered for the purpose. The second access violation kills the program,
as if the handler were no longer registered. Using diagnostic code not shown
I've made sure the handler is still registered, but somehow it's not being
called by Cygwin's internal fault handling. Or maybe there's some subtle
mistake in my use of the signal functions. Any advice would be appreciated.
..mark
#include <setjmp.h>
#include <signal.h>
#include <stdio.h>
volatile int step = 0;
sigjmp_buf trapoline;
void
segv_handler(int sig)
{
printf("case %d: SIGSEGV handled\n", step++);
siglongjmp(trapoline, step);
}
int
main()
{
struct sigaction sa;
sa.sa_handler = segv_handler;
sa.sa_flags = 0;
sigemptyset(&sa.sa_mask);
sigaction(SIGSEGV, &sa, NULL);
switch(sigsetjmp(trapoline, 0)) {
case 0:
printf("case %d reached\n", step);
printf("case %d: %08X\n", *(int *) 42);
++step;
case 1:
printf("case %d reached\n", step);
printf("case %d: %08X\n", *(int *) 42);
++step;
default:
printf("case %d reached\n", step);
break;
}
return 0;
}
--
Problem reports: http://cygwin.com/problems.html
FAQ: http://cygwin.com/faq/
Documentation: http://cygwin.com/docs.html
Unsubscribe info: http://cygwin.com/ml/#unsubscribe-simple