Index: llvm/trunk/lib/Fuzzer/FuzzerIO.h =================================================================== --- llvm/trunk/lib/Fuzzer/FuzzerIO.h +++ llvm/trunk/lib/Fuzzer/FuzzerIO.h @@ -64,6 +64,8 @@ void RemoveFile(const std::string &Path); +void DiscardOutput(int Fd); + } // namespace fuzzer #endif // LLVM_FUZZER_IO_H Index: llvm/trunk/lib/Fuzzer/FuzzerIO.cpp =================================================================== --- llvm/trunk/lib/Fuzzer/FuzzerIO.cpp +++ llvm/trunk/lib/Fuzzer/FuzzerIO.cpp @@ -97,13 +97,13 @@ OutputFile = NewOutputFile; if (EF->__sanitizer_set_report_fd) EF->__sanitizer_set_report_fd(reinterpret_cast(OutputFd)); - CloseFile(2); + DiscardOutput(2); } } } void CloseStdout() { - CloseFile(1); + DiscardOutput(1); } void Printf(const char *Fmt, ...) { Index: llvm/trunk/lib/Fuzzer/FuzzerIOPosix.cpp =================================================================== --- llvm/trunk/lib/Fuzzer/FuzzerIOPosix.cpp +++ llvm/trunk/lib/Fuzzer/FuzzerIOPosix.cpp @@ -75,6 +75,14 @@ unlink(Path.c_str()); } +void DiscardOutput(int Fd) { + FILE* Temp = fopen("/dev/null", "w"); + if (!Temp) + return; + dup2(fileno(Temp), Fd); + fclose(Temp); +} + std::string DirName(const std::string &FileName) { char *Tmp = new char[FileName.size() + 1]; memcpy(Tmp, FileName.c_str(), FileName.size() + 1); Index: llvm/trunk/lib/Fuzzer/FuzzerIOWindows.cpp =================================================================== --- llvm/trunk/lib/Fuzzer/FuzzerIOWindows.cpp +++ llvm/trunk/lib/Fuzzer/FuzzerIOWindows.cpp @@ -141,6 +141,14 @@ _unlink(Path.c_str()); } +void DiscardOutput(int Fd) { + FILE* Temp = fopen("nul", "w"); + if (!Temp) + return; + _dup2(_fileno(Temp), Fd); + fclose(Temp); +} + static bool IsSeparator(char C) { return C == '\\' || C == '/'; }