The code was duplicated in multiple places. Pick-to: 6.5 Change-Id: If2ab30b7afbf6d2f99c9fffd999218802b734d5e Reviewed-by: Ahmad Samir <a.samirh78@gmail.com> (cherry picked from commit b119fee87d5579dc1c4bfc2f508b0e3a75d69fa3) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org> (cherry picked from commit f9bdb80ef1f0d56d9585df61f0e209fe0b718443)
42 lines
1.1 KiB
C++
42 lines
1.1 KiB
C++
// Copyright (C) 2025 Intel Corporation.
|
|
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
|
|
|
|
// This file is added to some test helpers that don't link to Qt, so don't
|
|
// use Qt #includes here.
|
|
|
|
#ifdef _WIN32
|
|
# include <windows.h>
|
|
#else
|
|
# include <unistd.h>
|
|
#endif
|
|
#if __has_include(<sys/resource.h>)
|
|
# include <sys/resource.h>
|
|
#endif
|
|
#ifdef _MSC_VER
|
|
# include <crtdbg.h>
|
|
#endif
|
|
|
|
static void disableCoreDumps()
|
|
{
|
|
#ifdef _WIN32
|
|
// Windows: suppress the OS error dialog box.
|
|
SetErrorMode(SEM_NOGPFAULTERRORBOX | SEM_FAILCRITICALERRORS | SEM_NOOPENFILEERRORBOX);
|
|
# ifdef _MSC_VER
|
|
// MSVC: Suppress runtime's crash notification dialog.
|
|
_CrtSetReportMode(_CRT_ERROR, _CRTDBG_MODE_DEBUG);
|
|
# endif
|
|
#elif defined(RLIMIT_CORE)
|
|
// Unix: set our core dump limit to zero to request no dialogs.
|
|
if (struct rlimit rlim; getrlimit(RLIMIT_CORE, &rlim) == 0) {
|
|
rlim.rlim_cur = 0;
|
|
setrlimit(RLIMIT_CORE, &rlim);
|
|
}
|
|
#endif
|
|
}
|
|
|
|
struct DisableCoreDumps
|
|
{
|
|
DisableCoreDumps() { disableCoreDumps(); }
|
|
};
|
|
[[maybe_unused]] DisableCoreDumps disableCoreDumpsConstructorFunction;
|