From 37f24d8c1cea9ae85a72c695ec4f3b5f9174a157 Mon Sep 17 00:00:00 2001 From: nastys <@a.a> Date: Mon, 10 Jan 2022 14:15:04 +0100 Subject: [PATCH] Log maxfiles to file and stderr on *NIX --- rpcs3/rpcs3qt/gui_application.cpp | 12 ++++++++++++ rpcs3/util/sysinfo.cpp | 14 ++++++++++++++ rpcs3/util/sysinfo.hpp | 2 ++ 3 files changed, 28 insertions(+) diff --git a/rpcs3/rpcs3qt/gui_application.cpp b/rpcs3/rpcs3qt/gui_application.cpp index fc12231951..02075e78af 100644 --- a/rpcs3/rpcs3qt/gui_application.cpp +++ b/rpcs3/rpcs3qt/gui_application.cpp @@ -35,6 +35,7 @@ #include #include #include +#include #include @@ -105,6 +106,17 @@ bool gui_application::Init() 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)) { return false; diff --git a/rpcs3/util/sysinfo.cpp b/rpcs3/util/sysinfo.cpp index fad4ee2fe2..ce95411627 100755 --- a/rpcs3/util/sysinfo.cpp +++ b/rpcs3/util/sysinfo.cpp @@ -11,6 +11,7 @@ #include "stringapiset.h" #else #include +#include #include #include #endif @@ -358,6 +359,19 @@ std::string utils::get_OS_version() 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) { return utils::rounded_div(val, 1'000'000) * 1'000'000; diff --git a/rpcs3/util/sysinfo.hpp b/rpcs3/util/sysinfo.hpp index 4de9030164..987da95b68 100755 --- a/rpcs3/util/sysinfo.hpp +++ b/rpcs3/util/sysinfo.hpp @@ -51,6 +51,8 @@ namespace utils std::string get_OS_version(); + int get_maxfiles(); + ullong get_tsc_freq(); u64 get_total_memory();