QProcess/Doc: clarify that started() may be emitted very early

On Windows, process creation is synchronous so we will always emit
either started() or errorOccurred() before QProcess::start() returns.
This condition doesn't currently happen on Unix systems, but we could do
that because we're now using vfork() on most platforms, so the child
process has either successfully execve()d or _exit()ed before
QProcessPrivate::startProcess continued.

Drive-by reorganization of the code to remove the one-line \note in the
middle of the docs.

Pick-to: 6.6 6.5
Fixes: QTBUG-120968
Task-number: QTCREATORBUG-30066
Change-Id: I4d0668e0fae5299551ff91480828a68e62fdacec
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@gmx.de>
Reviewed-by: Jarek Kobus <jaroslaw.kobus@qt.io>
(cherry picked from commit 8e1f9169cac78b0df4dab17ed05765fdab842d07)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
This commit is contained in:
Thiago Macieira 2024-01-15 09:55:35 -08:00 committed by Qt Cherry-pick Bot
parent 03ca126bb6
commit 078c68462e

View File

@ -1985,7 +1985,8 @@ QProcessEnvironment QProcess::processEnvironment() const
Returns \c true if the process was started successfully; otherwise
returns \c false (if the operation timed out or if an error
occurred).
occurred). If the process had already started successfully before this
function, it returns immediately.
This function can operate without an event loop. It is
useful when writing non-GUI applications and when performing
@ -2164,18 +2165,22 @@ QByteArray QProcess::readAllStandardError()
/*!
Starts the given \a program in a new process, passing the command line
arguments in \a arguments. See setProgram() for information about how
QProcess searches for the executable to be run.
QProcess searches for the executable to be run. The OpenMode is set to \a
mode. No further splitting of the arguments is performed.
The QProcess object will immediately enter the Starting state. If the
process starts successfully, QProcess will emit started(); otherwise,
errorOccurred() will be emitted.
errorOccurred() will be emitted. Do note that on platforms that are able to
start child processes synchronously (notably Windows), those signals will
be emitted before this function returns and this QProcess object will
transition to either QProcess::Running or QProcess::NotRunning state,
respectively. On others paltforms, the started() and errorOccurred()
signals will be delayed.
\note Processes are started asynchronously, which means the started()
and errorOccurred() signals may be delayed. Call waitForStarted() to make
sure the process has started (or has failed to start) and those signals
have been emitted.
\note No further splitting of the arguments is performed.
Call waitForStarted() to make sure the process has started (or has failed
to start) and those signals have been emitted. It is safe to call that
function even if the process starting state is already known, though the
signal will not be emitted again.
\b{Windows:} The arguments are quoted and joined into a command line
that is compatible with the \c CommandLineToArgvW() Windows function.
@ -2184,8 +2189,6 @@ QByteArray QProcess::readAllStandardError()
not follow the \c CommandLineToArgvW() rules is cmd.exe and, by
consequence, all batch scripts.
The OpenMode is set to \a mode.
If the QProcess object is already running a process, a warning may be
printed at the console, and the existing process will continue running
unaffected.