From c849c48d19cc0b086f98688d760fa6e008adc50e Mon Sep 17 00:00:00 2001 From: Thiago Macieira Date: Tue, 11 Oct 2022 09:38:42 -0700 Subject: Autotest/Unix: request zero-sized core dumps for crashing code MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Unix systems have got crash loggers in the past 15-20 years, notably macOS and Linux (abrtd, systemd-coredumpd, etc.). By setting the core dump limit to zero, those tools should be mostly inhibited from running and thus not interfere with the parent process' timeouts. Even for systems without core dump loggers, disabling the writing of a core dump to the filesystem should also help. Pick-to: 6.4 Change-Id: I12a088d1ae424825abd3fffd171d112d0671effe Reviewed-by: MÃ¥rten Nordheim --- tests/auto/network/socket/qtcpserver/crashingServer/main.cpp | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) (limited to 'tests/auto/network/socket') diff --git a/tests/auto/network/socket/qtcpserver/crashingServer/main.cpp b/tests/auto/network/socket/qtcpserver/crashingServer/main.cpp index 25cc100919..c14c429520 100644 --- a/tests/auto/network/socket/qtcpserver/crashingServer/main.cpp +++ b/tests/auto/network/socket/qtcpserver/crashingServer/main.cpp @@ -8,15 +8,23 @@ # include #endif #ifdef Q_OS_UNIX +# include # include #endif int main(int argc, char *argv[]) { - // Windows: Suppress crash notification dialog. #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 + QCoreApplication app(argc, argv); if (argc < 1) { fprintf(stderr, "Need a port number\n"); -- cgit v1.2.3