From bec66636c8a2eefe9b0c5e701ffa6cc7d469bce7 Mon Sep 17 00:00:00 2001 From: Ivan Solovev Date: Mon, 3 Feb 2025 15:11:05 +0100 Subject: [PATCH] QProcess/Unix: add an actual check of DisableCoreDumps flag The original patch that added this feature was disabling the core dumps unconditionally. I guess the check was simply forgotten. Amends 9df6e8ad3b3a7a57af87e6a3fef2ef793610cb3d. Found in Qt 6.9 API review. Change-Id: If3f9cb35d11a0262241a465626a25f6d7d2bbdb4 Reviewed-by: Edward Welbourne Reviewed-by: Thiago Macieira (cherry picked from commit 9860f6522919d154dd4f95ff6f6ae58d3e4c435e) Reviewed-by: Qt Cherry-pick Bot --- src/corelib/io/qprocess_unix.cpp | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/src/corelib/io/qprocess_unix.cpp b/src/corelib/io/qprocess_unix.cpp index c7412b6a7da..dd3946a7443 100644 --- a/src/corelib/io/qprocess_unix.cpp +++ b/src/corelib/io/qprocess_unix.cpp @@ -886,12 +886,14 @@ static const char *applyProcessParameters(const QProcess::UnixProcessParameters } // Disable core dumps near the end. This isn't expected to fail. - if (struct rlimit lim; getrlimit(RLIMIT_CORE, &lim) == 0 && lim.rlim_cur) { - // We'll leave rlim_max untouched, so the child can set it back if it - // wants to. We don't expect setrlimit() to fail, so we ignore its - // return value. - lim.rlim_cur = 0; - (void) setrlimit(RLIMIT_CORE, &lim); + if (params.flags.testFlag(QProcess::UnixProcessFlag::DisableCoreDumps)) { + if (struct rlimit lim; getrlimit(RLIMIT_CORE, &lim) == 0 && lim.rlim_cur) { + // We'll leave rlim_max untouched, so the child can set it back if it + // wants to. We don't expect setrlimit() to fail, so we ignore its + // return value. + lim.rlim_cur = 0; + (void) setrlimit(RLIMIT_CORE, &lim); + } } // Apply UID and GID parameters last. This isn't expected to fail either: