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 <edward.welbourne@qt.io>
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
(cherry picked from commit 9860f6522919d154dd4f95ff6f6ae58d3e4c435e)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
This commit is contained in:
Ivan Solovev 2025-02-03 15:11:05 +01:00 committed by Qt Cherry-pick Bot
parent 11599cb379
commit bec66636c8

View File

@ -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: