diff --git a/tests/auto/testlib/selftests/silent_fatal/tst_silent_fatal.cpp b/tests/auto/testlib/selftests/silent_fatal/tst_silent_fatal.cpp index 57aa1f702cc..a7b4324992d 100644 --- a/tests/auto/testlib/selftests/silent_fatal/tst_silent_fatal.cpp +++ b/tests/auto/testlib/selftests/silent_fatal/tst_silent_fatal.cpp @@ -5,6 +5,29 @@ #include #include +#if defined(Q_OS_WIN) && defined(Q_CC_MSVC) +# include +#endif +#ifdef Q_OS_UNIX +# include +# include +#endif + +void disableCoreDumps() +{ +#if defined(Q_OS_WIN) && defined(Q_CC_MSVC) + // Windows: Suppress crash notification dialog. + _CrtSetReportMode(_CRT_ERROR, _CRTDBG_MODE_DEBUG); +#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 +} +Q_CONSTRUCTOR_FUNCTION(disableCoreDumps) + class tst_SilentFatal : public QObject { Q_OBJECT