[lkml]   [1999]   [Jan]   [1]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
Messages in this thread
    SubjectRe: core files
    On 981230, Michael Elizabeth Chastain wrote:
    > You could do a lot of *this* in user space by having a library function
    > set the default value for all signals, or just SIGSEGV, to a function
    > that uses some kind of IPC, such as writing to a fifo whose name includes
    > the uid. I wonder if it's possible to use preloading to inject that
    > snippet of code into an existing executable without relinking it and
    > without touching libc.

    Yes. The only hard part I see is getting the executable filename.
    #include <stdlib.h>
    #include <sys/types.h>
    #include <sys/stat.h>
    #include <fcntl.h>
    #include <signal.h>
    #include <unistd.h>

    void init_libcore(void) __attribute__((constructor));

    sighandler(int signo)
    struct {
    int signo;
    pid_t pid;
    } s;
    int fd;

    s.signo = signo; = getpid();
    fd = open(getenv("SIG_FIFO"), O_WRONLY);
    write(fd, &s, sizeof s);

    struct sigaction act;

    act.sa_handler = sighandler;
    act.sa_flags = SA_RESETHAND;
    sigaction(SIGSEGV, &act, NULL);
    % gcc -fPIC -o core.o -c core.c
    % gcc -shared -o core.o
    % LD_PRELOAD=./core SIG_FIFO=$HOME/.crash_handler_fifo bash

    A program to listen to the fifo should be straightforward.
    ICQ UIN: 56155810

    To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
    the body of a message to
    Please read the FAQ at

     \ /
      Last update: 2005-03-22 13:49    [W:0.021 / U:0.740 seconds]
    ©2003-2016 Jasper Spaans. hosted at Digital OceanAdvertise on this site