Skip to content

Commit 288999b

Browse files
author
Dan Gohman
committed
Factor out the handler work from SignalHandler into a helper function,
and change llvm::sys::RunInterruptHandlers to call that function directly instead of calling SignalHandler, because the rest of SignalHandler invokes side effects which aren't appropriate, including raising the signal. llvm-svn: 104896
1 parent a817a19 commit 288999b

File tree

1 file changed

+12
-5
lines changed

1 file changed

+12
-5
lines changed

llvm/lib/System/Unix/Signals.inc

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,14 @@ static void UnregisterHandlers() {
111111
}
112112

113113

114+
/// RemoveFilesToRemove - Process the FilesToRemove list. This function
115+
/// should be called with the SignalsMutex lock held.
116+
static void RemoveFilesToRemove() {
117+
while (!FilesToRemove.empty()) {
118+
FilesToRemove.back().eraseFromDisk(true);
119+
FilesToRemove.pop_back();
120+
}
121+
}
114122

115123
// SignalHandler - The signal handler that runs.
116124
static RETSIGTYPE SignalHandler(int Sig) {
@@ -126,10 +134,7 @@ static RETSIGTYPE SignalHandler(int Sig) {
126134
sigprocmask(SIG_UNBLOCK, &SigMask, 0);
127135

128136
SignalsMutex.acquire();
129-
while (!FilesToRemove.empty()) {
130-
FilesToRemove.back().eraseFromDisk(true);
131-
FilesToRemove.pop_back();
132-
}
137+
RemoveFilesToRemove();
133138

134139
if (std::find(IntSigs, IntSigsEnd, Sig) != IntSigsEnd) {
135140
if (InterruptFunction) {
@@ -153,7 +158,9 @@ static RETSIGTYPE SignalHandler(int Sig) {
153158
}
154159

155160
void llvm::sys::RunInterruptHandlers() {
156-
SignalHandler(SIGINT);
161+
SignalsMutex.acquire();
162+
RemoveFilesToRemove();
163+
SignalsMutex.release();
157164
}
158165

159166
void llvm::sys::SetInterruptFunction(void (*IF)()) {

0 commit comments

Comments
 (0)