QProcess not work with start but work with startDetached



  • I have a problem with start dos application with Qprocess::start.

    @
    #include <QtGui/QApplication>
    #include <QProcess>

    int main(int argc, char *argv[])
    {
    QApplication a(argc, argv);

    QProcess *process = new QProcess();
    process->start("c:\\femag\\wfemag_02-2013.exe");
    
    return a.exec&#40;&#41;;
    

    }

    @
    the executed application fails at some point with this kind of error "invalid handle".

    when I use
    @
    process->startDetached("c:\femag\wfemag_02-2013.exe");
    @

    the application starts OK. But I need to use
    @
    process->start().

    @

    I tried this on windows7 32 or 64 bit with same issue. But in windows8 it is working ok.

    Can somebody help me with this problem?


  • Moderators

    You should be using unix-style paths in Qt, not this Windows heresy. But this is not the cause of your problem, of course.

    There are some restrictions in QProcess (especially on Windows), it might be a bit tricky. First, I would recommend to specify the working directory yourself. Maybe the app you are trying to run expects a certain file to be present in the working dir? Does the app you are trying to run do some magical threading stuff? Or maybe it requires some changes to env?



  • the app is 3rd party for electromagnetic calculations (https://www.dropbox.com/s/bx8w5f1b42eutz6/wfemag_02-2013.exe)

    it should be start alone without any file in working directory.

    what the process->startDetached() make differently as process->start()
    ?

    I need check end of calculation. Therefore I wait for process finished.


  • Moderators

    I don't know the internal details, sorry.



  • The difference between start() and startDetached() is that when calling start() you open the process as part of your current process (so to speak) so if you close your applications process the child process will be closed. With startDetached however you start a standalone process that is independent from your applications process


  • Moderators

    That is clear. But the question is different - what causes the attached process to fail?



  • maybe it has a built in protection against anti-debugging...


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.