Subject: Do signals work?
From: [email-masked] (Kevin Hughes)

27 Nov 1997 13:49:47 -0800
Message-ID: <[email-masked]>
Mime-Version: 1.0
Content-Type: text/plain; charset="us-ascii"
Content-Transfer-Encoding: 8bit
To: "Gnuwin95 (E-mail)" <[email-masked]>

I have the latest coolview  cygwin and have been trying to use the signals. I can install the handler but cannot get the handler to be entered. I have tried the following program:

#include <fcntl.h>
#include <time.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <signal.h>
#include <setjmp.h>

long count=0;
int handled;
jmp_buf env;

void sigill_handler(int sig)
{
	printf("handler\n");
	while (count >0)
	{
		count--;
		return;
	}
	handled=(0==0);
	longjmp(env,1);	
};

int main(int argc, char* argv[])
{   
	long* address;
	long sum;
	int error;
	struct sigaction act;

    	act.sa_handler=&sigill_handler;
    	act.sa_flags=0;

    	error=sigaction(SIGSEGV,&act,NULL);	// install handler
	if (error != 0) 
	{
		printf("failed to install handler\n");
		return 1;
	}

	handled=(0==1);
	count=0;

	address=(long*)(((long)&count) & 0xffff0000);
	address+=1024*1024;

	if (setjmp(env)==0)
	{
		while (!handled)
		{
			address=address+4096;
			sum+=*address;
		}
	}
	return 0;
}

The program runs fine or unix (solaris) - it simply print handler as required. On gnuwin95 I get

(c:\a.exe 28547) In cygwin_except_handler exc C0000005 at 401148 sp 240F16C

I have tried debugging it using gdb which reports that the program has had a SIGSEGV but does not appear to enter my handler. Continue simply repeats the report.

Has anyone any ideas why I cannot catch these signals - cleary gdb is doing.

Many thanks 

Kevin

-
For help on using this list (especially unsubscribing), send a message to
"[email-masked]" with one line of text: "help".