Skip to content

Commit

Permalink
Stopgap fix for EMFILE
Browse files Browse the repository at this point in the history
  • Loading branch information
RicardoLuis0 committed Feb 22, 2024
1 parent 6802b33 commit 194762f
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
7 changes: 6 additions & 1 deletion src/common/filesystem/source/files.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,11 @@
#include <algorithm>
#include <assert.h>
#include <string.h>
#include "printf.h"
#include "files_internal.h"

#include <cerrno>

namespace FileSys {

#ifdef _WIN32
Expand All @@ -53,7 +56,9 @@ FILE *myfopen(const char *filename, const char *flags)
#else
auto widename = toWide(filename);
auto wideflags = toWide(flags);
return _wfopen(widename.c_str(), wideflags.c_str());
FILE * f = _wfopen(widename.c_str(), wideflags.c_str());
if(!f && errno == EMFILE) I_FatalError("Too many file descriptors open");
return f;
#endif
}

Expand Down
4 changes: 4 additions & 0 deletions src/common/platform/win32/i_main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,8 @@
#include <commctrl.h>
#include <richedit.h>

#include <cstdio>

#include <processenv.h>
#include <shellapi.h>
#include <VersionHelpers.h>
Expand Down Expand Up @@ -148,6 +150,8 @@ int DoMain (HINSTANCE hInstance)
TIMECAPS tc;
DEVMODE displaysettings;

_setmaxstdio(8192);

// Do not use the multibyte __argv here because we want UTF-8 arguments
// and those can only be done by converting the Unicode variants.
Args = new FArgs();
Expand Down

0 comments on commit 194762f

Please sign in to comment.