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: