Make sure that there is no case where a signal can occur leaving a partially

written output file.  This is important because crashing testcases often write
part of a file out, and the testing harness decides the file is up-to-date next
time the test is run.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@2303 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Chris Lattner
2002-04-18 19:55:25 +00:00
parent bac27a49b1
commit 76d12299b5
12 changed files with 58 additions and 0 deletions
+8
View File
@@ -18,6 +18,7 @@
#include "llvm/Function.h"
#include "llvm/PassManager.h"
#include "Support/CommandLine.h"
#include "Support/Signals.h"
#include <memory>
#include <string>
#include <fstream>
@@ -141,6 +142,10 @@ int main(int argc, char **argv) {
return 1;
}
Out = new std::ofstream(OutputFilename.c_str());
// Make sure that the Out file gets unlink'd from the disk if we get a
// SIGINT
RemoveFileOnSignal(OutputFilename);
} else {
if (InputFilename == "-") {
OutputFilename = "-";
@@ -162,6 +167,9 @@ int main(int argc, char **argv) {
delete Out;
return 1;
}
// Make sure that the Out file gets unlink'd from the disk if we get a
// SIGINT
RemoveFileOnSignal(OutputFilename);
}
}