? Elk Scheme, Linux sigaction, SA_SIGINFO, siginfo_t ? 
Author Message
 ? Elk Scheme, Linux sigaction, SA_SIGINFO, siginfo_t ?

Is there any planned development of SA_SIGINFO and siginfo_t for
signal.h, as defined by POSIX.4 for Linux?

 I am trying to compile the Elk Scheme, and in the garbage collector, it
needs to be able to find the address of the illegal memory reference
that caused a SIGSEGV.  From what I can tell so far, it looks like
POSIX.4 defines, in signal.h, ifdef _POSIX_REALTIME_SIGNALS, a siginfo_t
and a SA_SIGINFO, which will send that information to the signal handler
installed with sigaction.

clipped from: elk-3.0/src/heapgen.c
------------------------------------
InstallHandler () {
#ifdef SIGSEGV_SIGINFO
    struct sigaction sact;
    sigset_t mask;

    sact.sa_handler = (void (*)())PagefaultHandler;
    sigemptyset (&mask);
    sact.sa_mask = mask;
    sact.sa_flags = SA_SIGINFO;
    if (sigaction (SIGSEGV, &sact, 0) == -1) {
        perror ("sigaction"); exit (1);
    }
#else
    (void)signal (SIGSEGV, (void (*)())PagefaultHandler);
#endif

Quote:
}

---------
and above there:
----------------------
#ifdef SIGSEGV_SIGINFO
static void PagefaultHandler (sig, sip, ucp) siginfo_t *sip; ucontext_t
*ucp; {
    char *addr;
------------------------
And then later on in that handler function it goes:
----------------------------
#ifdef SIGSEGV_SIGINFO
    if (sip == 0)
        Fatal_Error ("SIGSEGV handler got called with zero siginfo_t");
    addr = sip->si_addr;
#endif
----------------------------

From POSIX.4, Programming in the Real World, ISBN 1-565922-074-0, pg.
300, I found:
---------------------------------
typedef struct {
   ...
   int          si_signo;       /* signal number (redundant) */
   int          si_code;        /* cause of signal */
   union sigval si_value;       /* Queued data value */
   ...

Quote:
} siginfo_t

---------------------------------
 I assume this would contain a sigcontext structure??

---
 So am I barking up the wrong tree?  What function do I call to fill a
sigcontext structure and get ahold of that address?  It wouldn't be hard
to add another #ifdef block for Linux, if there is a standard way to
find addr.

Any Ideas?

--

http://www.*-*-*.com/ ~karlheg
(K0D) AYG-GE01  Portland, OR, USA
:) Proudly running Linux 2.0.22 and GNU public software!



Sat, 17 Apr 1999 03:00:00 GMT  
 ? Elk Scheme, Linux sigaction, SA_SIGINFO, siginfo_t ?

Quote:
> Is there any planned development of SA_SIGINFO and siginfo_t for
> signal.h, as defined by POSIX.4 for Linux?

Check out sigcontext.h in /usr/include/asm.  There is a sigcontext
structure that (although not documented anywhere) is passed to the user's
signal handler.  Field cr2 is the address of the illegal memory reference.

Declare your signal handler like this:

void segvhandler()
int signo;
struct sigcontext_struct context;

{
        context.cr2:          /* do something with this */

Quote:
}

--



Mon, 19 Apr 1999 03:00:00 GMT  
 ? Elk Scheme, Linux sigaction, SA_SIGINFO, siginfo_t ?

Quote:

> > Is there any planned development of SA_SIGINFO and siginfo_t for
> > signal.h, as defined by POSIX.4 for Linux?

> Check out sigcontext.h in /usr/include/asm.  There is a sigcontext
> structure that (although not documented anywhere) is passed to the user's
> signal handler.  Field cr2 is the address of the illegal memory reference.

> Declare your signal handler like this:

> void segvhandler()
> int signo;
> struct sigcontext_struct context;

> {
>         context.cr2:          /* do something with this */
> }

! Oh!  I didn't know that it gets passed to the signal handler!  OK,
I'll try that.
:) Thank you!
--

http://www.teleport.com/~karlheg
(K0D) AYG-GE01  Portland, OR, USA
:) Proudly running Linux 2.0.23+ and GNU public software!


Mon, 19 Apr 1999 03:00:00 GMT  
 
 [ 3 post ] 

 Relevant Pages 

1. Elk-Scheme on Linux

2. elk on linux-elf

3. Scheme compiler for Elk??

4. elk on linux

5. Compiling elk under linux

6. Scheme (Elk) help

7. Xaw+Scheme/Elk experience

8. ELK and scheme as an extension language

9. Elk/Scheme on IBM RT/PC

10. Elk 3.0 on Linux

11. Elk/Scheme on IBM RT/PC

12. ILU support for Elk or Scheme-48 or MIT Scheme?

 

 
Powered by phpBB® Forum Software