From: Hualet Wang <mr.asianwang@gmail.com>
To: libc-help@sourceware.org
Subject: Confused by the __restore_rt symbol
Date: Wed, 16 May 2018 02:16:00 -0000 [thread overview]
Message-ID: <CA+iZjYStRW+K83W2KgEORpag72VCpo7-OstASrOWYN1e2gjqgg@mail.gmail.com> (raw)
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
next reply other threads:[~2018-05-16 2:16 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-05-16 2:16 Hualet Wang [this message]
2018-05-22 18:58 ` Adhemerval Zanella
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=CA+iZjYStRW+K83W2KgEORpag72VCpo7-OstASrOWYN1e2gjqgg@mail.gmail.com \
--to=mr.asianwang@gmail.com \
--cc=libc-help@sourceware.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).