Process and child process
-
@SPlatten Then read from https://doc.qt.io/qt-5/qprocess.html#readAllStandardError to see whether the application started by QProcess prints any warnings/errors.
And you still should check https://doc.qt.io/qt-5/qprocess.html#error and/or connect a slot to https://doc.qt.io/qt-5/qprocess.html#errorOccurred as an error can occur after starting the process. -
@jsulm , I just added:
qdbg() << mspobjProcess->readAllStandardError(); qdbg() << mspobjProcess->readAllStandardOutput();And the output in the log file was:
QIODevice::read (QProcess): device not open QIODevice::read (QProcess): device not open -
@jsulm , I just added:
qdbg() << mspobjProcess->readAllStandardError(); qdbg() << mspobjProcess->readAllStandardOutput();And the output in the log file was:
QIODevice::read (QProcess): device not open QIODevice::read (QProcess): device not open@SPlatten
I am not 100% sure that @jsulm has noticed you are usingstartDetached(), and I'm not 100% sure whether for that you must instead usesetStandardErrorFile()etc. instead, as per https://doc.qt.io/qt-5/qprocess.html#startDetached ?EDIT Hold on! The overload you are using, https://doc.qt.io/qt-5/qprocess.html#startDetached-1, is
static. So you're not going to have amspobjProcessinstance? For more control over it use the https://doc.qt.io/qt-5/qprocess.html#startDetached overload I referred to earlier. -
@SPlatten
I am not 100% sure that @jsulm has noticed you are usingstartDetached(), and I'm not 100% sure whether for that you must instead usesetStandardErrorFile()etc. instead, as per https://doc.qt.io/qt-5/qprocess.html#startDetached ?EDIT Hold on! The overload you are using, https://doc.qt.io/qt-5/qprocess.html#startDetached-1, is
static. So you're not going to have amspobjProcessinstance? For more control over it use the https://doc.qt.io/qt-5/qprocess.html#startDetached overload I referred to earlier. -
-
@jsulm To be honest, probably because the example I came across for QProcess was using it. What I want is to launch the child process and allow the launching process to carry on without being held up.
-
@jsulm To be honest, probably because the example I came across for QProcess was using it. What I want is to launch the child process and allow the launching process to carry on without being held up.
@SPlatten said in Process and child process:
What I want is to launch the child process and allow the launching process to carry on without being held up.
That happens without
startDetached(),QProcessruns asynchronously. You only needstartDetachedbasically if you want to sub-process not to e.g. get terminated when your process exits. -
@SPlatten said in Process and child process:
What I want is to launch the child process and allow the launching process to carry on without being held up.
That happens without
startDetached(),QProcessruns asynchronously. You only needstartDetachedbasically if you want to sub-process not to e.g. get terminated when your process exits. -
-
@jsulm , I get the PID so I can verify its actually running since neither start or startDetached return anything.
-
@jsulm , I get the PID so I can verify its actually running since neither start or startDetached return anything.
@SPlatten said in Process and child process:
@jsulm , I get the PID so I can verify its actually running since neither start or startDetached return anything.
well, Process has the started and stateChanged signal for that.
https://doc.qt.io/qt-5/qprocess.html#startedyou should actually listen to the stateChanged signal, to see if it changes from Running to NotRunning
-
@jsulm , I get the PID so I can verify its actually running since neither start or startDetached return anything.
@SPlatten
You have other things you can look at instead, likeQProcess::stateChangedsignal for clues.While you get it working, you may find
start()is easier to work with thanstartDetached().EDIT Sigh, looks like 3 of us are all trying to answer :)
If it's not secret, you might like to share with us the full command you are running, including the arguments, in case we can spot anything for you....
-
3 People 3 times the same thought
Up Top🙌
-
@SPlatten
You have other things you can look at instead, likeQProcess::stateChangedsignal for clues.While you get it working, you may find
start()is easier to work with thanstartDetached().EDIT Sigh, looks like 3 of us are all trying to answer :)
If it's not secret, you might like to share with us the full command you are running, including the arguments, in case we can spot anything for you....
@JonB I just tried start and it didn't work, I got errors in the Application Output:
QObject: Cannot create children for a parent that is in a different thread. (Parent is QProcess(0x101e0b420), parent's thread is QThread(0x101e0b880), current thread is clsThread(0x122c1bcc0) -
@JonB I just tried start and it didn't work, I got errors in the Application Output:
QObject: Cannot create children for a parent that is in a different thread. (Parent is QProcess(0x101e0b420), parent's thread is QThread(0x101e0b880), current thread is clsThread(0x122c1bcc0) -
@SPlatten said in Process and child process:
Why does startDetached take a qint64 for the PID as the last parameter but the QProcess function pid returns not a qint64 but a Q_PID?
Why are these different types?Don't use
Q_PIDfor this (Windows). Useqint64 QProcess::processId() const. -
@JonB I just tried start and it didn't work, I got errors in the Application Output:
QObject: Cannot create children for a parent that is in a different thread. (Parent is QProcess(0x101e0b420), parent's thread is QThread(0x101e0b880), current thread is clsThread(0x122c1bcc0) -
@SPlatten said in Process and child process:
QObject: Cannot create children for a parent that is in a different thread.
That would explain a lot...! :)
-
@JonB, I think I said from the start these are two different processes, not threads in the same process.
@SPlatten said in Process and child process:
I think I said from the start these are two different processes
This is clear.
I asked because the warning you posted comes when using threads.