-
Suggestion
-
Resolution: Unresolved
-
P3: Somewhat important
-
None
-
6.0, 6.1, 6.2, 6.3, 6.4, 6.5, 6.6, 6.7, 6.8
-
None
The Qt 5.15.16 source has the comment:
Q_PID QProcess::pid() const // ### Qt 6 remove or rename this method to processInformation()
However, this promised function does not exist in Qt 6.
This means it is impossible to use the process handle or thread handle that is owned by the QProcess to interact with the child process.
Most of the Win32 API uses a process or thread handle, not process or thread IDs.
While it is possible to use Win32 OpenProcess(DWORD dwDesiredAccess, BOOL bInheritHandle, DWORD dwProcessId) to create a new handle to the process from the process ID, that then requires the application to handle the permissions, inheritance and lifetime of that new handle separately to the lifetime of the QProcess.
It also means that anyone requiring a handle to the main thread of the child process (eg to post an event) has to take multiple steps to find it, then usually cache that result and attempt to keep the lifetime equal to the handle already owned by the QProcess.
This is a source of unnecessary complication and error.
Additionally, the documentation is misleading or incomplete.
QProcess::processId() is not a replacement for QProcess::pid().
If there is another way to find the _PROCESS_INFORMATION struct that pid() used to return, this must be explicitly documented as the replacement for QProcess::pid()
Note: This is currently blocking us from updating to Qt 6