Message-ID: <30E4AB64FBD5D01191E500805FC108F00479756A@ex1.elcsci.com> From: Mehmet Alpay To: "'Eli Zaretskii'" Cc: "'djgpp AT delorie DOT com'" Subject: RE: can't seem to get signal handling to work Date: Thu, 27 Jan 2000 09:20:25 -0800 MIME-Version: 1.0 X-Mailer: Internet Mail Service (5.5.2448.0) Content-Type: text/plain; charset="iso-8859-1" Reply-To: djgpp AT delorie DOT com Well, I have to hand it to you sir: you are right on the money! :-) The program was indeed running under NT, and the error window title was "ntvdm.exe - Application Error" The code itself was an example I took directly from Ira Pohl's "A Book on C", which is attached below. Are there any work-arounds for this problem? Thanks a lot for your help and the quick response. Mehmet Alpay Here's the code that causes the problem: #include #include #include #define MAXSTRING 100 void int_handler(int sig); int fib(int n); int main(void) { int i; signal(SIGINT, int_handler); for (i=0; i<46; ++i) printf("fib(%2d) = %d\n", i, fib(i)); return 0; } void int_handler(int sig) { char answer[MAXSTRING]; printf("\n\n%s%d\n\n%s", "Interrupt received! Signal = ", sig, "Do you wish to continue or quit? "); scanf("%s", answer); if (*answer == 'c') signal(SIGINT, int_handler); else exit(1); } int fib(int n) { if (n<=1) return n; else return (fib(n-1)+fib(n-2)); } -----Original Message----- From: Eli Zaretskii [mailto:eliz AT is DOT elta DOT co DOT il] Sent: Wednesday, January 26, 2000 11:27 PM To: Mehmet Alpay Cc: 'djgpp AT delorie DOT com' Subject: Re: can't seem to get signal handling to work On Wed, 26 Jan 2000, Mehmet Alpay wrote: > I wrote a somewhat long simulation program and I want to be able to > "interrupt" it every once in a while to check on its progress. However, the > little function I wrote for SIGINT handling doesn't seem to work properly - > or something else is getting messed up! In any event, whenever I hit Ctrl-C > while the program is running, I get the following pop-up error window: > > The instruction at "0x0f003453" referenced memory at "0xffffffff". The > memory could not be "read". > Click on OK to terminate the application > Click on CANCEL to debug the application On what OS did that happen? Is it NT by any chance? And what happens if you click CANCEL? > I did include the signal.h header file in the program, and it seems to run > just fine when I compile it - again using gcc - under Linux. Any ideas? Please post the code that installs the signal handler and the handler itself. It is next to impossible to help you without knowing how did you write your code. In general, catching signals works very well in DJGPP, except on NT, where it usually crashes the program (due to a blatant bug in NT's DOS emulator, ntvdm.exe).