summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorThiago Macieira <thiago.macieira@intel.com>2023-03-17 08:50:32 -0700
committerVolker Hilsheimer <volker.hilsheimer@qt.io>2023-05-15 00:12:41 +0200
commit6b561ccf44257489a2984a4a97785b1e6ef56902 (patch)
tree4c2eff4255450d7a4875b868ce31f47484be0d7c
parent29b2fe40dc778ec73da7e5643fcfd8979d8ecebc (diff)
QProcess/Unix: use pid_t for the pid
Qt 5 and earlier versions used to share this member with Windows, where we needed to store a pointer. We had the Q_PID public type, which was removed in commit b73d5a0511bed8c3ccc504e74c52a61d4d3749b4 (6.0). That commit made the QProcess::processId() public API use qint64, which is fine. But we don't need to store more bits than the OS actually requires. This further reduces QProcessPrivate's size to 688 bytes on 64-bit Unix, with 5 bytes of tail padding. Pick-to: 6.5 Change-Id: Icfe44ecf285a480fafe4fffd174d3fa9345872c0 Reviewed-by: Ahmad Samir <a.samirh78@gmail.com> Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io> Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@gmx.de>
-rw-r--r--src/corelib/io/qprocess_p.h2
-rw-r--r--src/corelib/io/qprocess_unix.cpp8
2 files changed, 4 insertions, 6 deletions
diff --git a/src/corelib/io/qprocess_p.h b/src/corelib/io/qprocess_p.h
index 6dfc4565fb..973f9b3abf 100644
--- a/src/corelib/io/qprocess_p.h
+++ b/src/corelib/io/qprocess_p.h
@@ -284,9 +284,9 @@ public:
std::function<void(void)> childProcessModifier;
};
std::unique_ptr<UnixExtras> unixExtras;
- qint64 pid = 0;
QSocketNotifier *stateNotifier = nullptr;
Q_PIPE childStartedPipe[2] = {INVALID_Q_PIPE, INVALID_Q_PIPE};
+ pid_t pid = 0;
int forkfd = -1;
#endif
diff --git a/src/corelib/io/qprocess_unix.cpp b/src/corelib/io/qprocess_unix.cpp
index a5e52fb793..8c07927ad4 100644
--- a/src/corelib/io/qprocess_unix.cpp
+++ b/src/corelib/io/qprocess_unix.cpp
@@ -474,8 +474,7 @@ void QProcessPrivate::startProcess()
if (unixExtras && unixExtras->childProcessModifier)
ffdflags |= FFD_USE_FORK;
- pid_t childPid;
- forkfd = ::vforkfd(ffdflags , &childPid, execChild2, &execChild1);
+ forkfd = ::vforkfd(ffdflags, &pid, execChild2, &execChild1);
int lastForkErrno = errno;
if (forkfd == -1) {
@@ -490,7 +489,6 @@ void QProcessPrivate::startProcess()
return;
}
- pid = qint64(childPid);
Q_ASSERT(pid > 0);
// parent
@@ -724,7 +722,7 @@ void QProcessPrivate::terminateProcess()
qDebug("QProcessPrivate::terminateProcess() pid=%jd", intmax_t(pid));
#endif
if (pid > 0)
- ::kill(pid_t(pid), SIGTERM);
+ ::kill(pid, SIGTERM);
}
void QProcessPrivate::killProcess()
@@ -733,7 +731,7 @@ void QProcessPrivate::killProcess()
qDebug("QProcessPrivate::killProcess() pid=%jd", intmax_t(pid));
#endif
if (pid > 0)
- ::kill(pid_t(pid), SIGKILL);
+ ::kill(pid, SIGKILL);
}
bool QProcessPrivate::waitForStarted(const QDeadlineTimer &deadline)