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
virtual void setupChildProcess()
if (_inheritFileDescriptors == false)
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.