diff options
author | Reid Spencer <rspencer@reidspencer.com> | 2006-08-07 05:34:08 +0000 |
---|---|---|
committer | Reid Spencer <rspencer@reidspencer.com> | 2006-08-07 05:34:08 +0000 |
commit | a8e80c51882c008e1e29194ea9c808ede1164eff (patch) | |
tree | 674a7754d26f98745c525b1aef936c4a15a0104e /lib/System/Unix | |
parent | bffdc36c3820100e806520d0c5608a7752324d4b (diff) | |
download | external_llvm-a8e80c51882c008e1e29194ea9c808ede1164eff.zip external_llvm-a8e80c51882c008e1e29194ea9c808ede1164eff.tar.gz external_llvm-a8e80c51882c008e1e29194ea9c808ede1164eff.tar.bz2 |
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.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@29540 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/System/Unix')
-rw-r--r-- | lib/System/Unix/Signals.inc | 9 |
1 files changed, 5 insertions, 4 deletions
diff --git a/lib/System/Unix/Signals.inc b/lib/System/Unix/Signals.inc index 05b9abf..941e031 100644 --- a/lib/System/Unix/Signals.inc +++ b/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); |