| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "android_webview/common/aw_crash_handler.h" | 5 #include "android_webview/common/aw_crash_handler.h" |
| 6 | 6 |
| 7 #include <android/log.h> | 7 #include <android/log.h> |
| 8 #include <signal.h> | 8 #include <signal.h> |
| 9 #include <sys/prctl.h> | 9 #include <sys/prctl.h> |
| 10 #include <sys/syscall.h> | 10 #include <sys/syscall.h> |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 42 // We served our purpose. Now restore the old crash handlers. If the embedder | 42 // We served our purpose. Now restore the old crash handlers. If the embedder |
| 43 // did register a custom crash handler, it will be invoked by the kernel after | 43 // did register a custom crash handler, it will be invoked by the kernel after |
| 44 // this function returns. Otherwise, this will end up invoking the default | 44 // this function returns. Otherwise, this will end up invoking the default |
| 45 // signal disposition. | 45 // signal disposition. |
| 46 for (uint32_t i = 0; i < arraysize(kExceptionSignals); ++i) { | 46 for (uint32_t i = 0; i < arraysize(kExceptionSignals); ++i) { |
| 47 if (sigaction(kExceptionSignals[i], &old_handlers[i], NULL) == -1) { | 47 if (sigaction(kExceptionSignals[i], &old_handlers[i], NULL) == -1) { |
| 48 signal(kExceptionSignals[i], SIG_DFL); | 48 signal(kExceptionSignals[i], SIG_DFL); |
| 49 } | 49 } |
| 50 } | 50 } |
| 51 | 51 |
| 52 if ((info != NULL && info->si_pid) || sig == SIGABRT) { | 52 if ((info != NULL && SI_FROMUSER(info)) || sig == SIGABRT) { |
| 53 // This signal was triggered by somebody sending us the signal with kill(). | 53 // This signal was triggered by somebody sending us the signal with kill(). |
| 54 // In order to retrigger it, we have to queue a new signal by calling | 54 // In order to retrigger it, we have to queue a new signal by calling |
| 55 // kill() ourselves. The special case (si_pid == 0 && sig == SIGABRT) is | 55 // kill() ourselves. The special case (si_pid == 0 && sig == SIGABRT) is |
| 56 // due to the kernel sending a SIGABRT from a user request via SysRQ. | 56 // due to the kernel sending a SIGABRT from a user request via SysRQ. |
| 57 if (syscall(__NR_tgkill, getpid(), syscall(__NR_gettid), sig) < 0) { | 57 if (syscall(__NR_tgkill, getpid(), syscall(__NR_gettid), sig) < 0) { |
| 58 // If we failed to kill ourselves resort to terminating uncleanly. | 58 // If we failed to kill ourselves resort to terminating uncleanly. |
| 59 exit(1); | 59 exit(1); |
| 60 } | 60 } |
| 61 } | 61 } |
| 62 } | 62 } |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 109 LOG(ERROR) << "Error while overriding handler for signal " | 109 LOG(ERROR) << "Error while overriding handler for signal " |
| 110 << kExceptionSignals[i]; | 110 << kExceptionSignals[i]; |
| 111 } | 111 } |
| 112 } | 112 } |
| 113 | 113 |
| 114 crash_handler_registered = true; | 114 crash_handler_registered = true; |
| 115 } | 115 } |
| 116 | 116 |
| 117 } // namespace crash_handler | 117 } // namespace crash_handler |
| 118 } // namespace android_webview | 118 } // namespace android_webview |
| OLD | NEW |