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
diff --git a/tools/llvm-dis/dis.cpp b/tools/llvm-dis/dis.cpp
index a317cb3..e14dcdc 100644
--- a/tools/llvm-dis/dis.cpp
+++ b/tools/llvm-dis/dis.cpp
@@ -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 @@
              << "': 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);
       }
     }
   }
diff --git a/tools/llvm-dis/llvm-dis.cpp b/tools/llvm-dis/llvm-dis.cpp
index a317cb3..e14dcdc 100644
--- a/tools/llvm-dis/llvm-dis.cpp
+++ b/tools/llvm-dis/llvm-dis.cpp
@@ -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 @@
              << "': 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);
       }
     }
   }