Is QProcess::finished emitted if the child process crashes?

qprocess: destroyed while process is still running
qprocess tutorial
qprocess write
qprocess read output
qprocess python
qprocess example linux
qprocess windows
qprocess command

The documentation says that the error() signal will be emitted if the child process crashes, but would finished() be emitted as well or is it only emitted when it exits successfully?

Yes. And it returns you status, as docs state:

void QProcess::finished ( int exitCode, QProcess::ExitStatus exitStatus ) [signal]

QProcess::NormalExit    0   The process exited normally.
QProcess::CrashExit 1   The process crashed.

c++, Is QProcess::finished emitted if the child process crashes? void QProcess::​finished ( int exitCode, QProcess::ExitStatus exitStatus ) [signal]  Is QProcess::finished emitted if the child process crashes? Yes. And it returns you status, as docs state: void QProcess::finished ( int exitCode, QProcess::ExitStatus exitStatus ) [signal] QProcess::NormalExit 0 The process exited normally.

You can find out by testing it. Write a small program that does a NULL pointer dereference (this will guarantee a crash):

struct Foo {
    int a;
};

int main()
{
    Foo* foo = 0;
    int d = foo->a;
}

Make sure you build without optimization so that the dereference doesn't get optimized out. Then run it in a QProcess and check whether finished() is being emitted.

QProcess Class, The finished() signal provides the exit code and exit status of the process as If an error occurs at any point in time, QProcess will emit the errorOccurred() signal. Anything the child process writes to its standard output and standard error will be written QProcess::Crashed, 1, The process crashed some time after starting​  Stack Overflow Public questions and answers; given that the process is killed. share Is QProcess::finished emitted if the child process crashes? 4.

My program crashes if QProcess is restarted directly when it has , I have created a program that is supposed to run a process over and over again, object it is that has emitted the signal, I had to use a QSignalMapper to map the Why not connect the signal QProcess::finished(int) to your slot? [QProcess] QProcess still in running state when the child process crashes. [signal] void QProcess:: finished (int exitCode, QProcess::ExitStatus exitStatus) This signal is emitted when the process finishes. exitCode is the exit code of the process (only valid for normal exits), and exitStatus is the exit status. After the process has finished, the buffers in QProcess are still intact. You can still read any data that

QProcess Class Reference, enum ProcessError { FailedToStart, Crashed, Timedout, ReadError, WriteError, UnknownError } void finished (int,QProcess::ExitStatus) The finished() signal provides the exit code and exit status of the process as arguments, and you can also If an error occurs at any point in time, QProcess will emit the error() signal. [signal] void QProcess:: finished (int exitCode, QProcess::ExitStatus exitStatus) This signal is emitted when the process finishes. exitCode is the exit code of the process, and exitStatus is the exit status. After the process has finished, the buffers in QProcess are still intact. You can still read any data that the process may have written

QProcess, QProcess enters the Running state and emits PySide. QProcess.exitCode() to obtain the exit code of the last process that finished, and PySide. Crashed, The process crashed some time after starting successfully. Anything the child process writes to its standard output and standard error will be written to the standard  If the function is successful then *``pid`` is set to the process identifier of the started process. Note that the child process may exit and the PID may become invalid without notice. Furthermore, after the child process exits, the same PID may be recycled and used by a completely different process.

Browse the source code of qtbase/src/corelib/io/qprocess.cpp, 140, along with QProcess, to set the environment for child processes. It. 141, cannot be QProcess emits readyRead() when data is. 518, available on 694, \value Crashed The process crashed some time after starting. 695, successfully 824, \fn void QProcess::finished(int exitCode, QProcess::ExitStatus exitStatus). 825. QProcess forwards the input of the main process onto the running process. The child process reads its standard input from the same source as the main process. Note that the main process must not try to read its standard input while the child process is running.

Comments
  • No. It is not true. Qt is crossplatform library. If it works in some way on a particular system, does not mean it will work same on other system in general.
  • @Lol4t0 I'm not sure what you mean with "not true." The test will make it clear, without a doubt, whether or not QProcess emits the signal. In your answer, you found the actual documentation that clears it up. Here, I simply provided a way to get some empirical evidence. The assumption of course is that if the signal is emitted on the OP's platform, then the same holds true for all supported platforms. Assumptions aren't that great though, so obviously your answer is the better one :)
  • Assumptions are bad first of all because QProcess is platfrom dependednt part of Qt. You said that 'You can find out by testing it'. But you can't actually. You can only assume