Avoid closing stdin/stdout/stderr standard streams

This commit is contained in:
Rangi committed 2026-07-13 13:02:46 -04:00
1 parent 8ab6190f96
commit e9fa1e4e94
11 files changed
+42 -22

No files matched your search

+2 -1
View File
@@ -19,6 +19,7 @@
#include "helpers.hpp"
#include "linkdefs.hpp"
#include "platform.hpp"
#include "util.hpp" // xfclose
#include "verbosity.hpp"
#include "version.hpp"
@@ -446,7 +447,7 @@ void obj_ReadFile(std::string const &filePath, size_t fileID) {
if (!file) {
fatal("Failed to open file \"%s\": %s", fileName, strerror(errno));
}
Defer closeFile{[&] { fclose(file); }};
Defer closeFile{[&] { xfclose(file); }};
// First, check if the object is a RGBDS object, a SDCC one, or neither.
// A single `ungetc` is guaranteed to work.