Mailing-List: contact cygwin-help AT cygwin DOT com; run by ezmlm 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 Message-ID: <4a03a72c050823024012eb6fe7@mail.gmail.com> Date: Tue, 23 Aug 2005 11:40:19 +0200 From: znort Reply-To: znort AT delorie DOT com To: cygwin AT cygwin DOT com Subject: signal trouble Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Disposition: inline X-IsSubscribed: yes Content-Transfer-Encoding: 8bit X-MIME-Autoconverted: from quoted-printable to 8bit by delorie.com id j7N9flfZ006893 Could you tell/help me why the little code : #include #include #include jmp_buf context; int yog(int n) { char *p=NULL; printf("pass %d\n", n); if (n<=2) return 1; strcpy(p, "dfldflflmflkklfklflkmfdlfldfldlfdlkfd"); // must crash of course !!! return 1; } void resume(int sig) { longjmp(context, 6); //signal(SIGSEGV, resume); } int main(void) { int sig, i; char *x=NULL; for (i=0; i<3; i++) { signal(SIGSEGV, resume); sig = setjmp(context); if (sig == 0) { yog(1); yog(2); yog(3); //return 555; } else { fprintf(stderr, "ouch -- signal %d\n", sig); } } puts("end"); return 0; } gives just : pass 1 pass 2 pass 3 ouch -- signal 6 pass 1 pass 2 pass 3 Segmentation fault and not pass 1 pass 2 pass 3 ouch -- signal 6 pass 1 pass 2 pass 3 ouch -- signal 6 pass 1 pass 2 pass 3 ouch -- signal 6 Under cygwin gcc version 3.4.4 (cygming special) and Linux with gcc 3.3.5 same "strange" results... (no segmentation fault with cygwin anyway) (notes : Under Solaris x86 (gcc3.4.4) it works perfectly !?) I think I've forgotten something but where ? help me please -- Unsubscribe info: http://cygwin.com/ml/#unsubscribe-simple Problem reports: http://cygwin.com/problems.html Documentation: http://cygwin.com/docs.html FAQ: http://cygwin.com/faq/