From: David L. <le...@cs...> - 2002-03-20 12:38:49
|
Hi, MinGW 1.1 gcc 2.95.3-6 The program below demonstrates that execution is not resumed after a signal is handled. This program does work properly when built with Cygwin's gcc. Is this a known problem? If not, any suggestions on how to fix it? I just need this behavior at just one place in a program (blocked on select ()). Unfortunately, setjmp/longjmp doesn't seem to help. Any other alternatives? Thanks, David 8<----------8<----------8<----------8<----------8<----------8<----------8<---- /* Demonstrates that execution doesn't resume after a signal is caught and handled, when built with MinGW g++ 2.95.3-4. To build: gcc -o resume.exe resume.c -W -Wall To run: resume.exe then Ctrl-C after the "start sleep" printout appears. The "should see this message" printout should always appear. It doesn't when build with MinGW's gcc 2.95.3-4. */ #include <stdio.h> #include <stdlib.h> #include <unistd.h> #include <signal.h> #include <errno.h> void sig_handler (int sig) { printf ("caught signal %d\n", sig); } int main () { if (signal (SIGINT, sig_handler) == SIG_ERR) { fprintf (stderr, "failed to install signal handler"); return -1; } printf ("start sleep\n"); #ifdef _WIN32 _sleep (4000); #else sleep (4); #endif printf ("should see this message; finished sleep with errno %d\n", errno); return 0; } |