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 b73d5a0511 (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>
bb10
parent
29b2fe40dc
commit
6b561ccf44
|
|
@ -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
|
||||
|
||||
|
|
|
|||
|
|
@ -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)
|
||||
|
|
|
|||
Loading…
Reference in New Issue