summaryrefslogtreecommitdiffstats
path: root/llvm/lib/System/Unix
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2009-03-05 18:22:14 +0000
committerChris Lattner <sabre@nondot.org>2009-03-05 18:22:14 +0000
commitbbbbbf30bd11c5281bd294e4bfe59053e00ff943 (patch)
treec18fcc5c881733033c7b4f08ee322a39226d0a73 /llvm/lib/System/Unix
parenta7ec605dbda245781c9049c207ff291d7ea557e1 (diff)
downloadbcm5719-llvm-bbbbbf30bd11c5281bd294e4bfe59053e00ff943.tar.gz
bcm5719-llvm-bbbbbf30bd11c5281bd294e4bfe59053e00ff943.zip
move some code to gracefully handle the case when a handler crashes.
llvm-svn: 66171
Diffstat (limited to 'llvm/lib/System/Unix')
-rw-r--r--llvm/lib/System/Unix/Signals.inc10
1 files changed, 6 insertions, 4 deletions
diff --git a/llvm/lib/System/Unix/Signals.inc b/llvm/lib/System/Unix/Signals.inc
index ac0d982f4e5..f409cefcc35 100644
--- a/llvm/lib/System/Unix/Signals.inc
+++ b/llvm/lib/System/Unix/Signals.inc
@@ -57,6 +57,12 @@ static const int *const KillSigsEnd =
// SignalHandler - The signal handler that runs...
static RETSIGTYPE SignalHandler(int Sig) {
+ // Restore the signal behavior to default, so that the program actually
+ // crashes when we return and the signal reissues. This also ensures that if
+ // we crash in our signal handler that the program will terminate immediately
+ // instead of recursing in the signal handler.
+ signal(Sig, SIG_DFL);
+
if (FilesToRemove != 0)
while (!FilesToRemove->empty()) {
FilesToRemove->back().eraseFromDisk(true);
@@ -77,10 +83,6 @@ static RETSIGTYPE SignalHandler(int Sig) {
if (CallBacksToRun)
for (unsigned i = 0, e = CallBacksToRun->size(); i != e; ++i)
(*CallBacksToRun)[i].first((*CallBacksToRun)[i].second);
-
- // Restore the signal behavior to default, so that the program actually
- // crashes when we return and the signal reissues.
- signal(Sig, SIG_DFL);
}
// Just call signal
OpenPOWER on IntegriCloud