aboutsummaryrefslogtreecommitdiffstats
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
commit52a5f39e45a4c6299f6dc1243f6c4899a991137c (patch)
treeb2b308b6810e3f411964fb98fc47cc1a3569fec7
parentbdaaa1e25ef79a795400178255726fb1a246244d (diff)
downloadexternal_llvm-52a5f39e45a4c6299f6dc1243f6c4899a991137c.tar.gz
external_llvm-52a5f39e45a4c6299f6dc1243f6c4899a991137c.tar.bz2
external_llvm-52a5f39e45a4c6299f6dc1243f6c4899a991137c.zip
move some code to gracefully handle the case when a handler crashes.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@66171 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r--lib/System/Unix/Signals.inc10
1 files changed, 6 insertions, 4 deletions
diff --git a/lib/System/Unix/Signals.inc b/lib/System/Unix/Signals.inc
index ac0d982f4e..f409cefcc3 100644
--- a/lib/System/Unix/Signals.inc
+++ b/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