Details
-
Suggestion
-
Resolution: Done
-
P2: Important
-
4.6.2, 5.1.0
-
Win32
-
068baa9bb6d526cccc0c8bc7cdbb84bbdf137f95
Description
Currently, QProcess::start() creates a child process that inherits all the sockets and file handles of the parent process. This is useful in some cases, but in other cases it opens the door for hard-to-find bugs to sneak in – for example, the TCP connections that the parent process had open when the child process was spawned are held open until the child process exits.
When running under Mac or Unix/Linux, I can work around this problem by subclassing QProcess and overriding setupChildProcess(), like this:
class MyQNetProcess : public QProcess
{
[...]
#ifndef WIN32
virtual void setupChildProcess()
{
QProcess::setupChildProcess();
if (_inheritFileDescriptors == false)
}
#endif
However, that trick doesn't work under Windows. For Windows, I would need to pass FALSE as the bInheritFileHandles argument to CreateProcess(), but QProcessPrivate::startProcess() has it hard-coded as TRUE.
In some cases I can avoid the problem by calling QProcess::startDetached() instead of QProcess::start(), but doing it that way precludes me from piping data to the child process's stdin, or reading data from the child process's stdout, and sometimes I need to be able to do that.
Attachments
Issue Links
- is replaced by
-
QTBUG-4465 Make the Windows socket handle non-inheritable
-
- Closed
-
For Gerrit Dashboard: QTBUG-9350 | ||||||
---|---|---|---|---|---|---|
# | Subject | Branch | Project | Status | CR | V |
113808,19 | add a way to modify CreateProcess parameters | dev | qt/qtbase | Status: MERGED | -2 | 0 |