Automatically bump the max file descriptors for clementine to the maximum on Mac.
This commit is contained in:
parent
596b5471b1
commit
718be22d0d
22
src/main.cpp
22
src/main.cpp
@ -53,6 +53,11 @@
|
|||||||
|
|
||||||
#include <echonest/Config.h>
|
#include <echonest/Config.h>
|
||||||
|
|
||||||
|
#ifdef Q_OS_DARWIN
|
||||||
|
#include <sys/resource.h>
|
||||||
|
#include <sys/sysctl.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
#ifdef HAVE_LIBLASTFM
|
#ifdef HAVE_LIBLASTFM
|
||||||
#include "radio/lastfmservice.h"
|
#include "radio/lastfmservice.h"
|
||||||
@ -102,6 +107,23 @@ int main(int argc, char *argv[]) {
|
|||||||
// Do Mac specific startup to get media keys working.
|
// Do Mac specific startup to get media keys working.
|
||||||
// This must go before QApplication initialisation.
|
// This must go before QApplication initialisation.
|
||||||
mac::MacMain();
|
mac::MacMain();
|
||||||
|
|
||||||
|
// Bump the soft limit for the number of file descriptors from the default of 256 to
|
||||||
|
// the maximum (usually 1024).
|
||||||
|
struct rlimit limit;
|
||||||
|
getrlimit(RLIMIT_NOFILE, &limit);
|
||||||
|
|
||||||
|
// getrlimit() lies about the hard limit so we have to check sysctl.
|
||||||
|
int max_fd = 0;
|
||||||
|
size_t len = sizeof(max_fd);
|
||||||
|
sysctlbyname("kern.maxfilesperproc", &max_fd, &len, NULL, 0);
|
||||||
|
|
||||||
|
limit.rlim_cur = max_fd;
|
||||||
|
int ret = setrlimit(RLIMIT_NOFILE, &limit);
|
||||||
|
|
||||||
|
if (ret == 0) {
|
||||||
|
qDebug() << "Max fd:" << max_fd;
|
||||||
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
QCoreApplication::setApplicationName("Clementine");
|
QCoreApplication::setApplicationName("Clementine");
|
||||||
|
Loading…
x
Reference in New Issue
Block a user