public inbox for libc-help@sourceware.org
 help / color / mirror / Atom feed
* Confused by the __restore_rt symbol
@ 2018-05-16  2:16 Hualet Wang
  2018-05-22 18:58 ` Adhemerval Zanella
  0 siblings, 1 reply; 2+ messages in thread
From: Hualet Wang @ 2018-05-16  2:16 UTC (permalink / raw)
  To: libc-help

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

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2018-05-22 18:58 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-05-16  2:16 Confused by the __restore_rt symbol Hualet Wang
2018-05-22 18:58 ` Adhemerval Zanella

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).