Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. QProcess not work with start but work with startDetached
Qt 6.11 is out! See what's new in the release blog

QProcess not work with start but work with startDetached

Scheduled Pinned Locked Moved General and Desktop
7 Posts 3 Posters 8.7k Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • R Offline
    R Offline
    renocz
    wrote on last edited by
    #1

    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?

    1 Reply Last reply
    0
    • sierdzioS Offline
      sierdzioS Offline
      sierdzio
      Moderators
      wrote on last edited by
      #2

      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?

      (Z(:^

      1 Reply Last reply
      0
      • R Offline
        R Offline
        renocz
        wrote on last edited by
        #3

        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.

        1 Reply Last reply
        0
        • sierdzioS Offline
          sierdzioS Offline
          sierdzio
          Moderators
          wrote on last edited by
          #4

          I don't know the internal details, sorry.

          (Z(:^

          1 Reply Last reply
          0
          • B Offline
            B Offline
            b1gsnak3
            wrote on last edited by
            #5

            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

            1 Reply Last reply
            0
            • sierdzioS Offline
              sierdzioS Offline
              sierdzio
              Moderators
              wrote on last edited by
              #6

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

              (Z(:^

              1 Reply Last reply
              0
              • B Offline
                B Offline
                b1gsnak3
                wrote on last edited by
                #7

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

                1 Reply Last reply
                0

                • Login

                • Login or register to search.
                • First post
                  Last post
                0
                • Categories
                • Recent
                • Tags
                • Popular
                • Users
                • Groups
                • Search
                • Get Qt Extensions
                • Unsolved