Log maxfiles to file and stderr on *NIX

This commit is contained in:
nastys 2022-01-10 14:15:04 +01:00 committed by Ivan
parent 3571e6ef85
commit 37f24d8c1c
3 changed files with 28 additions and 0 deletions

View file

@ -35,6 +35,7 @@
#include <QDirIterator> #include <QDirIterator>
#include <QFileInfo> #include <QFileInfo>
#include <QSound> #include <QSound>
#include <QMessageBox>
#include <clocale> #include <clocale>
@ -105,6 +106,17 @@ bool gui_application::Init()
welcome->exec(); welcome->exec();
} }
// Check maxfiles
if (utils::get_maxfiles() < 4096)
{
QMessageBox::warning(nullptr,
tr("Warning"),
tr("The current limit of maximum file descriptors is too low.\n"
"Some games will crash.\n"
"\n"
"Please increase the limit before running RPCS3."));
}
if (m_main_window && !m_main_window->Init(m_with_cli_boot)) if (m_main_window && !m_main_window->Init(m_with_cli_boot))
{ {
return false; return false;

View file

@ -11,6 +11,7 @@
#include "stringapiset.h" #include "stringapiset.h"
#else #else
#include <unistd.h> #include <unistd.h>
#include <sys/resource.h>
#include <sys/utsname.h> #include <sys/utsname.h>
#include <errno.h> #include <errno.h>
#endif #endif
@ -358,6 +359,19 @@ std::string utils::get_OS_version()
return output; return output;
} }
int utils::get_maxfiles()
{
#ifdef _WIN32
// Virtually unlimited on Windows
return INT_MAX;
#else
struct rlimit limits;
ensure(getrlimit(RLIMIT_NOFILE, &limits) == 0);
return limits.rlim_cur;
#endif
}
static constexpr ullong round_tsc(ullong val) static constexpr ullong round_tsc(ullong val)
{ {
return utils::rounded_div(val, 1'000'000) * 1'000'000; return utils::rounded_div(val, 1'000'000) * 1'000'000;

View file

@ -51,6 +51,8 @@ namespace utils
std::string get_OS_version(); std::string get_OS_version();
int get_maxfiles();
ullong get_tsc_freq(); ullong get_tsc_freq();
u64 get_total_memory(); u64 get_total_memory();