qtestcase.cpp: use #ifdef RLIMIT_CORE to guard RLIMIT_CORE usage

Instead of trying to guess which OSes have this functionality.

Change-Id: I5ff8e16fcdcb4ffd9ab6fffd16ebc20fe7eca346
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
This commit is contained in:
Thiago Macieira 2022-05-03 18:17:41 -07:00
parent f7152a4bb7
commit 30067d102c

View File

@ -191,17 +191,17 @@ static bool hasSystemCrashReporter()
static void disableCoreDump()
{
#ifdef RLIMIT_CORE
bool ok = false;
const int disableCoreDump = qEnvironmentVariableIntValue("QTEST_DISABLE_CORE_DUMP", &ok);
if (ok && disableCoreDump) {
#if defined(Q_OS_UNIX) && !defined(Q_OS_INTEGRITY)
struct rlimit limit;
limit.rlim_cur = 0;
limit.rlim_max = 0;
if (setrlimit(RLIMIT_CORE, &limit) != 0)
qWarning("Failed to disable core dumps: %d", errno);
#endif
}
#endif
}
Q_CONSTRUCTOR_FUNCTION(disableCoreDump);