This is the mail archive of the libc-help@sourceware.org mailing list for the glibc project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Confused by the __restore_rt symbol


Hi there,

I'm trying to understand signal handling in linux recently, everything is
fine by now except the so called "signal trampoline" part,  I know it's
trying to call sigreturn,  but I'm totally confused by the  __restore_rt
and __restore symbol:

1. why does it appear in sigaction.c and exported by libphread ?
2. why __restore_rt shows up in the stacktrace if my test program (attached
bellow) linked against libpthread and otherwise not?

Please someone  shed some light on this,  that'll be much appreciated.

PS: compile the test program with `gcc -rdynamic test-sigaction.c  -o
test-sigaction`

========== test-sigaction.c ===========

#include <signal.h>
#include <stddef.h>
#include <stdio.h>
#include <unistd.h>

#include<execinfo.h>

#define SIZE 100

void print_backtrace()
{
        int size;
        void *buffer[SIZE];

        size = backtrace(buffer, SIZE);

        char** stack = backtrace_symbols(buffer, size);
        for (int i = 0; i < size; i++) {
                printf("%s \n", stack[i]);
        }
}


void
termination_handler (int signum)
{
printf("here in termination handler \n");
/*
while(1) {
printf("haha");
}
*/
print_backtrace();
}

int
main (void)
{
  struct sigaction new_action, old_action;

  /* Set up the structure to specify the new action. */
  new_action.sa_handler = termination_handler;
  sigemptyset (&new_action.sa_mask);
  new_action.sa_flags = 0;

  sigaction (SIGINT, &new_action, NULL);

  while(1) {
printf("here in the main loop \n ");
sleep(1);
  }
}



-- 
-- Hualet


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]