Mail Archives: djgpp/1996/06/29/03:34:28
Xref: | news2.mv.net comp.os.msdos.djgpp:5516
|
From: | snarfy AT goodguy DOT goodnet DOT com (Snarfy AT GoodNet DOT Com)
|
Newsgroups: | comp.os.msdos.djgpp
|
Subject: | __djgpp_exception_state is protected? (raise problems)
|
Date: | 29 Jun 1996 06:38:41 GMT
|
Organization: | Telesoft Corporation.
|
Lines: | 83
|
Message-ID: | <4r2j1h$lhe@news1.goodnet.com>
|
NNTP-Posting-Host: | goodnet.com
|
To: | djgpp AT delorie DOT com
|
DJ-Gateway: | from newsgroup comp.os.msdos.djgpp
|
This program explodes with a SIGSEGV when ran:
----------------Cut here---------------
#include <stdio.h>
#include <signal.h>
#include <setjmp.h>
#include <sys/exceptn.h>
void my_sig_handler(int signum)
{
unsigned long foo;
foo = __djgpp_exception_state->__eax;
printf("foo = %d\n", foo);
}
main()
{
signal(SIGINT, my_sig_handler);
raise(SIGINT);
return(0);
}
---------------Cut here-----------------
This program, very similar, does not:
---------------Cut here-----------------
#include <stdio.h>
#include <signal.h>
#include <setjmp.h>
#include <sys/exceptn.h>
void my_sig_handler(int signum)
{
unsigned long foo;
foo = __djgpp_exception_state->__eax;
printf("foo = %d\n", foo);
}
main()
{
signal(SIGINT, my_sig_handler);
printf("Press control-C dude.\n");
while(!kbhit()) {};
return(0);
}
---------------Cut Here-----------------
I have no idea why, but for some reason, __djgpp_exception_state is
either undefined or protected in the first program. It works fine
in the second program. Is this due to the hw_interrupt reflection?
On a side note, is there a reason why __djgpp_exception_state->__flags
is different than what 'should' be there? For example:
-------------cut here----------------------
#include <stdio.h>
#include <signal.h>
#include <setjmp.h>
#include <sys/exceptn.h>
jmp_buf my_buf;
void my_sig_handler(int signum)
{
unsigned int foo, bar;
foo = __djgpp_exception_state->__flags;
bar = my_buf->__flags;
printf("foo = %d, bar = %d\n", foo, bar);
}
main()
{
signal(SIGINT, my_sig_handler);
printf("Press Control-C dude\n");
while(!kbhit()) {setjmp(my_buf);}
}
------------cut here-------------------------
A sample output would be that my_bufs flags = 3216 while the other flags
are 13216 or 13214. The only thing I can think of is that control-C is
getting pressed inside of the kbhit() function or before setjmp finishes,
or that the interrupt flag is set.
Thanks
Josh
snarfy AT goodnet DOT com
- Raw text -