Index: lib/Fuzzer/FuzzerIO.h =================================================================== --- lib/Fuzzer/FuzzerIO.h +++ lib/Fuzzer/FuzzerIO.h @@ -61,6 +61,8 @@ void RemoveFile(const std::string &Path); +void DiscardOutput(int Fd); + } // namespace fuzzer #endif // LLVM_FUZZER_IO_H Index: lib/Fuzzer/FuzzerIO.cpp =================================================================== --- lib/Fuzzer/FuzzerIO.cpp +++ 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: lib/Fuzzer/FuzzerIOPosix.cpp =================================================================== --- lib/Fuzzer/FuzzerIOPosix.cpp +++ 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: lib/Fuzzer/FuzzerIOWindows.cpp =================================================================== --- lib/Fuzzer/FuzzerIOWindows.cpp +++ 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 == '/'; }