summaryrefslogtreecommitdiffstats
path: root/src/corelib/io/qprocess_unix.cpp
diff options
context:
space:
mode:
authorThiago Macieira <thiago.macieira@intel.com>2023-05-12 21:06:02 -0700
committerThiago Macieira <thiago.macieira@intel.com>2023-06-09 17:27:48 -0700
commitabd2ffc1497e6d13a607362f7f4362e2a6d00448 (patch)
tree5667fa02a4b450aa8f89e3554dca26014564cae7 /src/corelib/io/qprocess_unix.cpp
parente71c226d6f188abd811b28d3cb7529343f52d61f (diff)
QProcess/Unix: update the close-file-descriptors feature with a minimum
So that one can pass a few extra file descriptors to the child while still closing all the rest. strace -f of this test showed on Linux: [pid 117952] dup3(4, 0, 0) = 0 [pid 117952] dup3(9, 1, 0) = 1 [pid 117952] dup3(11, 2, 0) = 2 [pid 117952] close(12) = 0 [pid 117952] dup2(100, 3) = 3 [pid 117952] close_range(4, 2147483647, 0) = 0 [pid 117952] execve("testUnixProcessParameters/testUnixProcessParameters", ["testUnixProcessParameters/testUn"..., "file-descriptors2", "3", "100"], 0x561793dc87d0 /* 120 vars */ <unfinished ...> Pick-to: 6.6 Change-Id: I3e3bfef633af4130a03afffd175e984bf50b558d Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@gmx.de> Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Diffstat (limited to 'src/corelib/io/qprocess_unix.cpp')
-rw-r--r--src/corelib/io/qprocess_unix.cpp4
1 files changed, 2 insertions, 2 deletions
diff --git a/src/corelib/io/qprocess_unix.cpp b/src/corelib/io/qprocess_unix.cpp
index 7cd379f9fd..ea39962b9d 100644
--- a/src/corelib/io/qprocess_unix.cpp
+++ b/src/corelib/io/qprocess_unix.cpp
@@ -669,9 +669,9 @@ static void applyProcessParameters(const QProcess::UnixProcessParameters &params
// Close all file descriptors above stderr.
// This isn't expected to fail, so we ignore close()'s return value.
- if (params.flags.testFlag(QProcess::UnixProcessFlag::CloseNonStandardFileDescriptors)) {
+ if (params.flags.testFlag(QProcess::UnixProcessFlag::CloseFileDescriptors)) {
int r = -1;
- int fd = STDERR_FILENO + 1;
+ int fd = qMax(STDERR_FILENO + 1, params.lowestFileDescriptorToClose);
#if QT_CONFIG(close_range)
// On FreeBSD, this probably won't fail.
// On Linux, this will fail with ENOSYS before kernel 5.9.