[Interest] QProcess overload slot connection
thiago.macieira at intel.com
Thu Mar 14 18:28:20 CET 2019
On Thursday, 14 March 2019 09:59:33 PDT Jason H wrote:
> At a minimum the docs should elaborate that finished() only happens after
> started, and started only happens if the... process is scheduled?
Not exactly. The problem is the asynchronous nature of fork()+exec() on Unix
systems. On Windows, due to CreateProcess(), the process either fails to start
synchronously (start() returns false) or it has started[*].
But on Unix, because we must fork(), the parent process returns control to the
caller before the child process has found out if there's anything to be
exec()d in the first place. At this point, we already know the full path to
the file we want run, but there's no guarantee that exec() will work on it.
That's why we may have start() returning true, but the process still failing
to start on Unix. start() returns true if fork() succeeded, but it doesn't
know if exec() will.
I previously said on this thread that waitForStarted() is acceptable, since it
finishes rather quickly. But what may be acceptable for your code may not for
someone else and introducing that wait period was not deemed acceptable for
QProcess: the child process usually doesn't get scheduled until much later, so
suspending the parent process could introduce unacceptable delays.
[*] does not include process crashing before doing anything useful. By crash,
I also include failing to load the image due to corrupt executables, missing
Thiago Macieira - thiago.macieira (AT) intel.com
Software Architect - Intel System Software Products
More information about the Interest