X-Recipient: archive-cygwin AT delorie DOT com X-SWARE-Spam-Status: No, hits=-2.9 required=5.0 tests=AWL,BAYES_00,SPF_HELO_PASS,SPF_PASS X-Spam-Check-By: sourceware.org To: cygwin AT cygwin DOT com From: Mark Geisert Subject: 2nd occurrence of signal not being handled? Date: Sat, 19 Dec 2009 05:23:42 +0000 (UTC) Lines: 54 Message-ID: Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit User-Agent: Loom/3.14 (http://gmane.org/) X-IsSubscribed: yes Mailing-List: contact cygwin-help AT cygwin DOT com; run by ezmlm List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: cygwin-owner AT cygwin DOT com Mail-Followup-To: cygwin AT cygwin DOT com Delivered-To: mailing list cygwin AT cygwin DOT com 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 #include #include 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