lkml.org 
[lkml]   [1998]   [Dec]   [18]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Subjectsigaction SA_SIGINFO functionality
From
Date
Hi!

I can't get sigaction to work with SA_SIGINFO type of handler. I can see
that this is already in the kernel but does it work?

This is the program that doesn't work:

#include <stdio.h>
#include <asm/signal.h> /* ???! */
#include <setjmp.h>
jmp_buf main_loop;

void sigsegv_handler (int arg, struct siginfo *si, void *parg)
{
printf ("Signal SEGV! si = 0x%p\n", si);
longjmp (main_loop, 1);
}
int
main ()
{
char *f = NULL;
int retval;
struct sigaction sa;
sigaction (SIGSEGV, NULL, &sa);
sa.sa_sigaction = sigsegv_handler;
sa.sa_flags = SA_SIGINFO;
sigemptyset (&sa.sa_mask);
retval = sigaction (SIGSEGV, &sa, NULL);
if (retval < 0)
exit (10);
printf ("Entering the loop\n");

if (setjmp (main_loop))
printf ("Back at main_loop\n");
else
*f = 0;
return 0;
}

This results in the following output:
Signal SEGV! si = 0x(nil)
Back at main_loop
Signal SEGV! si = 0x(nil)
Back at main_loop
[...]


So, the si parameter (as well as parg) is NULL. The kernel didn't realize
that I have a siginfo type of handler, did it?

Is it something with the program or the kernel?

Thanks in advance,
--
| Josip Gracin
| Zagreb, Croatia
| mailto:grac@fly.cc.fer.hr, http://fly.cc.fer.hr/~grac

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.rutgers.edu
Please read the FAQ at http://www.tux.org/lkml/

\
 
 \ /
  Last update: 2005-03-22 13:46    [from the cache]
©2003-2011 Jasper Spaans