Make sure that there is no case where a signal can occur leaving a partially
authorChris Lattner <sabre@nondot.org>
Thu, 18 Apr 2002 19:55:25 +0000 (19:55 +0000)
committerChris Lattner <sabre@nondot.org>
Thu, 18 Apr 2002 19:55:25 +0000 (19:55 +0000)
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

12 files changed:
tools/as/as.cpp
tools/dis/dis.cpp
tools/gccas/gccas.cpp
tools/gccld/gccld.cpp
tools/link/link.cpp
tools/llc/llc.cpp
tools/llvm-as/as.cpp
tools/llvm-as/llvm-as.cpp
tools/llvm-dis/dis.cpp
tools/llvm-dis/llvm-dis.cpp
tools/llvm-link/llvm-link.cpp
tools/opt/opt.cpp

index 7bea711826e57c4b5ce0c8c3db87cb5b4058c05e..3e8a9eaf31a6b56230b3f1c766b3e0402de79239 100644 (file)
@@ -13,6 +13,7 @@
 #include "llvm/Assembly/Parser.h"
 #include "llvm/Bytecode/Writer.h"
 #include "Support/CommandLine.h"
+#include "Support/Signals.h"
 #include <fstream>
 #include <string>
 #include <memory>
@@ -70,6 +71,9 @@ int main(int argc, char **argv) {
         }
 
        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);
       }
     }
   
index a317cb316d564c976a6f7c243f0a1459a2c0e854..e14dcdc9a79dca5164075e25f0da6f7c99d17daf 100644 (file)
@@ -23,6 +23,7 @@
 #include "Support/DepthFirstIterator.h"
 #include "Support/PostOrderIterator.h"
 #include "Support/CommandLine.h"
+#include "Support/Signals.h"
 #include <fstream>
 #include <iostream>
 using std::cerr;
@@ -85,6 +86,10 @@ int main(int argc, char **argv) {
              << "': File exists! Sending to standard output.\n";
       } else {
         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);
       }
     }
   }
index 1bf1e8c0b7b741d662940c97040172a5533f5dc3..02d7cfe827f8904f8bf3019d186960d1a419f0a3 100644 (file)
@@ -20,6 +20,7 @@
 #include "llvm/Transforms/Scalar/PromoteMemoryToRegister.h"
 #include "llvm/Bytecode/WriteBytecodePass.h"
 #include "Support/CommandLine.h"
+#include "Support/Signals.h"
 #include <memory>
 #include <fstream>
 #include <string>
@@ -64,6 +65,9 @@ int main(int argc, char **argv) {
     return 1;
   }
 
+  // Make sure that the Out file gets unlink'd from the disk if we get a SIGINT
+  RemoveFileOnSignal(OutputFilename);
+
   // In addition to just parsing the input from GCC, we also want to spiff it up
   // a little bit.  Do this now.
   //
index 11595f7d22ce4ac154a0f333712626da0ea8674b..1e16aa100635338c7181052fe432b7ee64625ae2 100644 (file)
@@ -24,6 +24,7 @@
 #include "llvm/Transforms/ConstantMerge.h"
 #include "llvm/Transforms/IPO/GlobalDCE.h"
 #include "Support/CommandLine.h"
+#include "Support/Signals.h"
 #include <fstream>
 #include <memory>
 #include <algorithm>
@@ -161,6 +162,9 @@ int main(int argc, char **argv) {
   }
   Passes.add(new WriteBytecodePass(&Out));        // Write bytecode to file...
 
+  // Make sure that the Out file gets unlink'd from the disk if we get a SIGINT
+  RemoveFileOnSignal(OutputFilename+".bc");
+
   // Run our queue of passes all at once now, efficiently.
   Passes.run(Composite.get());
   Out.close();
index c4be6715cff6588faf6a7c851b77b927706045d5..6cb30a2bd4e69e695bb8a1bbf0f63571749d465a 100644 (file)
@@ -14,6 +14,7 @@
 #include "llvm/Bytecode/Writer.h"
 #include "llvm/Module.h"
 #include "Support/CommandLine.h"
+#include "Support/Signals.h"
 #include <fstream>
 #include <memory>
 #include <sys/types.h>     // For FileExists
@@ -126,6 +127,10 @@ int main(int argc, char **argv) {
       cerr << "Error opening '" << OutputFilename << "'!\n";
       return 1;
     }
+
+    // Make sure that the Out file gets unlink'd from the disk if we get a
+    // SIGINT
+    RemoveFileOnSignal(OutputFilename);
   }
 
   if (Verbose) cerr << "Writing bytecode...\n";
index 32a06dd291e9e8da3ecb9bc6924f259e369ed29f..b365c3900d8cc2673180a481e945d0873a2ba972 100644 (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);
     }
   }
   
index 7bea711826e57c4b5ce0c8c3db87cb5b4058c05e..3e8a9eaf31a6b56230b3f1c766b3e0402de79239 100644 (file)
@@ -13,6 +13,7 @@
 #include "llvm/Assembly/Parser.h"
 #include "llvm/Bytecode/Writer.h"
 #include "Support/CommandLine.h"
+#include "Support/Signals.h"
 #include <fstream>
 #include <string>
 #include <memory>
@@ -70,6 +71,9 @@ int main(int argc, char **argv) {
         }
 
        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);
       }
     }
   
index 7bea711826e57c4b5ce0c8c3db87cb5b4058c05e..3e8a9eaf31a6b56230b3f1c766b3e0402de79239 100644 (file)
@@ -13,6 +13,7 @@
 #include "llvm/Assembly/Parser.h"
 #include "llvm/Bytecode/Writer.h"
 #include "Support/CommandLine.h"
+#include "Support/Signals.h"
 #include <fstream>
 #include <string>
 #include <memory>
@@ -70,6 +71,9 @@ int main(int argc, char **argv) {
         }
 
        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);
       }
     }
   
index a317cb316d564c976a6f7c243f0a1459a2c0e854..e14dcdc9a79dca5164075e25f0da6f7c99d17daf 100644 (file)
@@ -23,6 +23,7 @@
 #include "Support/DepthFirstIterator.h"
 #include "Support/PostOrderIterator.h"
 #include "Support/CommandLine.h"
+#include "Support/Signals.h"
 #include <fstream>
 #include <iostream>
 using std::cerr;
@@ -85,6 +86,10 @@ int main(int argc, char **argv) {
              << "': File exists! Sending to standard output.\n";
       } else {
         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);
       }
     }
   }
index a317cb316d564c976a6f7c243f0a1459a2c0e854..e14dcdc9a79dca5164075e25f0da6f7c99d17daf 100644 (file)
@@ -23,6 +23,7 @@
 #include "Support/DepthFirstIterator.h"
 #include "Support/PostOrderIterator.h"
 #include "Support/CommandLine.h"
+#include "Support/Signals.h"
 #include <fstream>
 #include <iostream>
 using std::cerr;
@@ -85,6 +86,10 @@ int main(int argc, char **argv) {
              << "': File exists! Sending to standard output.\n";
       } else {
         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);
       }
     }
   }
index c4be6715cff6588faf6a7c851b77b927706045d5..6cb30a2bd4e69e695bb8a1bbf0f63571749d465a 100644 (file)
@@ -14,6 +14,7 @@
 #include "llvm/Bytecode/Writer.h"
 #include "llvm/Module.h"
 #include "Support/CommandLine.h"
+#include "Support/Signals.h"
 #include <fstream>
 #include <memory>
 #include <sys/types.h>     // For FileExists
@@ -126,6 +127,10 @@ int main(int argc, char **argv) {
       cerr << "Error opening '" << OutputFilename << "'!\n";
       return 1;
     }
+
+    // Make sure that the Out file gets unlink'd from the disk if we get a
+    // SIGINT
+    RemoveFileOnSignal(OutputFilename);
   }
 
   if (Verbose) cerr << "Writing bytecode...\n";
index f922dd82ccb62adf393f71a68d8017a6e209b850..f08567a6b89b6c57880d08dd7e1b1f20c46c8f21 100644 (file)
@@ -31,6 +31,7 @@
 #include "llvm/Transforms/Instrumentation/TraceValues.h"
 #include "llvm/Transforms/Instrumentation/ProfilePaths.h"
 #include "Support/CommandLine.h"
+#include "Support/Signals.h"
 #include <fstream>
 #include <memory>
 
@@ -174,6 +175,10 @@ int main(int argc, char **argv) {
       cerr << "Error opening " << OutputFilename << "!\n";
       return 1;
     }
+
+    // Make sure that the Output file gets unlink'd from the disk if we get a
+    // SIGINT
+    RemoveFileOnSignal(OutputFilename);
   }
 
   // Create a PassManager to hold and optimize the collection of passes we are