C   20

custom sigaction c

Guest on 30th May 2022 01:53:57 AM

  1. #include <stdio.h>
  2. #include <dlfcn.h>
  3. #include <signal.h>
  4.  
  5. int *
  6. __sigaction14(int sig, const struct sigaction * restrict act,
  7.               struct sigaction * restrict oact)
  8. {
  9.         int *(*original)(int sig, const struct sigaction * restrict act,
  10.                          struct sigaction * restrict oact);
  11.  
  12.         if (sig == SIGSEGV) {
  13.                 sig = SIGTRAP;
  14.                 printf("Fake SIGSEGV signal handler with a SIGTRAP one act=%p "
  15.                        "oact=%p\n", act, oact);
  16.         }
  17.  
  18.         original = dlsym(RTLD_NEXT, "__sigaction14");
  19.  
  20.         return (*original)(sig, act, oact);
  21. }

Raw Paste


Login or Register to edit or fork this paste. It's free.