Avoid closing stdin/stdout/stderr standard streams

This commit is contained in:
Rangi
2026-07-13 13:02:46 -04:00
parent 8ab6190f96
commit e9fa1e4e94
11 changed files with 42 additions and 22 deletions
+3 -2
View File
@@ -21,6 +21,7 @@
#include "helpers.hpp"
#include "itertools.hpp" // InsertionOrderedMap
#include "linkdefs.hpp"
#include "util.hpp" // xfclose
#include "asm/fstack.hpp"
#include "asm/lexer.hpp"
@@ -974,7 +975,7 @@ bool sect_BinaryFile(std::string const &name, uint32_t startPos) {
if (!file) {
return fstk_FileError(name, "`INCBIN`");
}
Defer closeFile{[&] { fclose(file); }};
Defer closeFile{[&] { xfclose(file); }};
if (fseek(file, 0, SEEK_END) == 0) {
if (unsigned long fsize = ftell(file);
@@ -1035,7 +1036,7 @@ bool sect_BinaryFileSlice(std::string const &name, uint32_t startPos, uint32_t l
if (!file) {
return fstk_FileError(name, "`INCBIN`");
}
Defer closeFile{[&] { fclose(file); }};
Defer closeFile{[&] { xfclose(file); }};
if (fseek(file, 0, SEEK_END) == 0) {
if (unsigned long fsize = ftell(file);