summaryrefslogtreecommitdiffstats
path: root/llvm/lib/System/Unix
diff options
context:
space:
mode:
authorReid Spencer <rspencer@reidspencer.com>2006-08-07 05:34:08 +0000
committerReid Spencer <rspencer@reidspencer.com>2006-08-07 05:34:08 +0000
commit448e2460e0d39e780aff889dca1a7b5df9a22f68 (patch)
treeda2e683ca032afda95986120cd65cbcba0b7553e /llvm/lib/System/Unix
parent5f9e301521a4c45ec49d0153c5dc81366da2681a (diff)
downloadbcm5719-llvm-448e2460e0d39e780aff889dca1a7b5df9a22f68.tar.gz
bcm5719-llvm-448e2460e0d39e780aff889dca1a7b5df9a22f68.zip
Make the removal of files use Path::eraseFromDisk just like it does for
the removal of directories. Using std::remove is indiscriminate and can lead to the removal of things like /dev/null if run as root. The Path::eraseFromDisk method ensures that we only ever remove regular files or directories, but never character or block special nodes. This should clear up the problem with usage like: llvm-as -o /dev/null which is used in the llvm-test makefiles. llvm-svn: 29540
Diffstat (limited to 'llvm/lib/System/Unix')
-rw-r--r--llvm/lib/System/Unix/Signals.inc9
1 files changed, 5 insertions, 4 deletions
diff --git a/llvm/lib/System/Unix/Signals.inc b/llvm/lib/System/Unix/Signals.inc
index 05b9abf8a30..941e031cc97 100644
--- a/llvm/lib/System/Unix/Signals.inc
+++ b/llvm/lib/System/Unix/Signals.inc
@@ -15,6 +15,7 @@
#include "Unix.h"
#include <vector>
#include <algorithm>
+#include <iostream>
#if HAVE_EXECINFO_H
# include <execinfo.h> // For backtrace().
#endif
@@ -30,7 +31,7 @@ bool StackTraceRequested = false;
/// InterruptFunction - The function to call if ctrl-c is pressed.
void (*InterruptFunction)() = 0;
-std::vector<std::string> *FilesToRemove = 0 ;
+std::vector<sys::Path> *FilesToRemove = 0 ;
std::vector<sys::Path> *DirectoriesToRemove = 0;
// IntSigs - Signals that may interrupt the program at any time.
@@ -112,7 +113,7 @@ void PrintStackTrace() {
RETSIGTYPE SignalHandler(int Sig) {
if (FilesToRemove != 0)
while (!FilesToRemove->empty()) {
- std::remove(FilesToRemove->back().c_str());
+ FilesToRemove->back().eraseFromDisk(true);
FilesToRemove->pop_back();
}
@@ -156,9 +157,9 @@ void sys::SetInterruptFunction(void (*IF)()) {
// RemoveFileOnSignal - The public API
void sys::RemoveFileOnSignal(const sys::Path &Filename) {
if (FilesToRemove == 0)
- FilesToRemove = new std::vector<std::string>;
+ FilesToRemove = new std::vector<sys::Path>;
- FilesToRemove->push_back(Filename.toString());
+ FilesToRemove->push_back(Filename);
std::for_each(IntSigs, IntSigsEnd, RegisterHandler);
std::for_each(KillSigs, KillSigsEnd, RegisterHandler);
OpenPOWER on IntegriCloud