summaryrefslogtreecommitdiffstats
path: root/sigchainlib
diff options
context:
space:
mode:
authorDmitriy Ivanov <dimitry@google.com>2015-04-02 18:30:22 -0700
committerDimitry Ivanov <dimitry@google.com>2015-04-03 17:14:19 +0000
commit34a0c208e7f808270e3e2189ae1a198b3fa8ed2e (patch)
treee4b9eb58f934ed04bf1a3a82499c78fa7452bcd7 /sigchainlib
parenta68a7cf8f3a6fef22d71a14350176115cb13857f (diff)
downloadart-34a0c208e7f808270e3e2189ae1a198b3fa8ed2e.zip
art-34a0c208e7f808270e3e2189ae1a198b3fa8ed2e.tar.gz
art-34a0c208e7f808270e3e2189ae1a198b3fa8ed2e.tar.bz2
Delegate SIG_DFL on sigaction to libc.
In the case when user registers SIG_DFL hanlder sigchainlib's handler tends to go into infinite loop because the function handling signals resets signal using by calling to signchain's own implementation. This cl fixes the problem by passing sigcations with SIG_DFL to the next sigaction (usually libc's). Bug: 19594886 Change-Id: I9eecf9afd1c7e6d1fe3cd1d4fc506383ecbebe04
Diffstat (limited to 'sigchainlib')
-rw-r--r--sigchainlib/sigchain.cc5
1 files changed, 3 insertions, 2 deletions
diff --git a/sigchainlib/sigchain.cc b/sigchainlib/sigchain.cc
index b4bd68b..e61fcd8 100644
--- a/sigchainlib/sigchain.cc
+++ b/sigchainlib/sigchain.cc
@@ -169,7 +169,8 @@ extern "C" int sigaction(int signal, const struct sigaction* new_action, struct
// action but don't pass it on to the kernel.
// Note that we check that the signal number is in range here. An out of range signal
// number should behave exactly as the libc sigaction.
- if (signal > 0 && signal < _NSIG && user_sigactions[signal].IsClaimed()) {
+ if (signal > 0 && signal < _NSIG && user_sigactions[signal].IsClaimed() &&
+ (new_action == nullptr || new_action->sa_handler != SIG_DFL)) {
struct sigaction saved_action = user_sigactions[signal].GetAction();
if (new_action != NULL) {
user_sigactions[signal].SetAction(*new_action, false);
@@ -210,7 +211,7 @@ extern "C" sighandler_t signal(int signal, sighandler_t handler) {
// action but don't pass it on to the kernel.
// Note that we check that the signal number is in range here. An out of range signal
// number should behave exactly as the libc sigaction.
- if (signal > 0 && signal < _NSIG && user_sigactions[signal].IsClaimed()) {
+ if (signal > 0 && signal < _NSIG && user_sigactions[signal].IsClaimed() && handler != SIG_DFL) {
oldhandler = reinterpret_cast<sighandler_t>(user_sigactions[signal].GetAction().sa_handler);
user_sigactions[signal].SetAction(sa, true);
return oldhandler;