On Tue, 2003-10-21 at 18:43, Martin Johansson wrote: > On Mon, Oct 20, 2003 at 11:07:40PM +1000, Ken Foskey wrote: > > > > > If anyone is on a very fresh version of K2.6 with extra patches can you > > please run this code and see if it crashes. It fails on all K2.6 up to > > Test6 release. I would be interested to hear of any success. > > I don't think it's related to the kernel version. > > > There should be no segfault and another signal caught. > > > > If there is any obvious blunder with this code let me know. Looks > > pretty right to me though I don't use signals much at all. > > The problem is that you never return from the signal handler. Now you're > getting a SIGSEGV during execution of the SIGSEGV handler and the signal is > probably forced to SIG_DFL, otherwise you could get an infinite signal > loop. Return from the handler instead of a longjmp and you should be ok.
The following code behaves the same under K 2.4 and K 2.6 so there is something different for SEGV to SIGINT. Can anyone explain? If you run this: ./a.out and hit ^C twice with a delay you get: $ ./a.out Hello World Hello World OUCH - I got signal 2 Hello World $ ***but*** $ ./a.out x Hello World OUCH segv - I got signal 11 Segmentation fault $ So returning from a segv signal will fail the program. #include <signal.h> #include <stdio.h> #include <unistd.h> void ouch_segv( int sig ) { printf( "OUCH segv - I got signal %d\n", sig ); (void) signal( SIGSEGV, SIG_DFL ); } void ouch( int sig ) { printf( "OUCH - I got signal %d\n", sig ); (void) signal( SIGINT, SIG_DFL ); } int main( int argc, char ** argv ) { char a; (void) signal( SIGINT, ouch ); (void) signal( SIGSEGV, ouch_segv ); while( 1 ) { printf( "Hello World\n" ); fflush( stdout ); if( argc > 1 ) { a = *((char*)0); } sleep( 1 ); } } -- Thanks KenF OpenOffice.org developer -- SLUG - Sydney Linux User's Group - http://slug.org.au/ More Info: http://lists.slug.org.au/listinfo/slug