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 state NotRunning but it is...

QProcess state NotRunning but it is...

Scheduled Pinned Locked Moved Unsolved General and Desktop
8 Posts 3 Posters 1.3k Views 2 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.
  • SPlattenS Offline
    SPlattenS Offline
    SPlatten
    wrote on last edited by
    #1

    I use QProcess to start an two instances of gedit, the instances are running and when I try to launch a third I test the processes already running using the state function, however the state returns NotRunning.

    When I launch the process I keep the instances of QProcess that were used to create the instances, are these not live?

    Is it because I'm starting the processes with startDetached ?

    Kind Regards,
    Sy

    1 Reply Last reply
    0
    • Christian EhrlicherC Online
      Christian EhrlicherC Online
      Christian Ehrlicher
      Lifetime Qt Champion
      wrote on last edited by
      #2

      startDetached() does what it means - it starts the process and has no control or information of it afterwards.

      Qt Online Installer direct download: https://download.qt.io/official_releases/online_installers/
      Visit the Qt Academy at https://academy.qt.io/catalog

      SPlattenS 1 Reply Last reply
      1
      • Christian EhrlicherC Christian Ehrlicher

        startDetached() does what it means - it starts the process and has no control or information of it afterwards.

        SPlattenS Offline
        SPlattenS Offline
        SPlatten
        wrote on last edited by
        #3

        @Christian-Ehrlicher , having now replaced startDetached with start the behaviour is the same it still returns the state NotRunning when it is.

        Kind Regards,
        Sy

        KroMignonK 1 Reply Last reply
        0
        • SPlattenS SPlatten

          @Christian-Ehrlicher , having now replaced startDetached with start the behaviour is the same it still returns the state NotRunning when it is.

          KroMignonK Offline
          KroMignonK Offline
          KroMignon
          wrote on last edited by KroMignon
          #4

          @SPlatten said in QProcess state NotRunning but it is...:

          having now replaced startDetached with start the behaviour is the same it still returns the state NotRunning when it is.

          Just to be sure, how do you check process state?
          As Qt is an asynchronous framework, you have give QProcess the ability to update his states, means the thread event loop must not be locked.

          It is an old maxim of mine that when you have excluded the impossible, whatever remains, however improbable, must be the truth. (Sherlock Holmes)

          SPlattenS 2 Replies Last reply
          0
          • KroMignonK KroMignon

            @SPlatten said in QProcess state NotRunning but it is...:

            having now replaced startDetached with start the behaviour is the same it still returns the state NotRunning when it is.

            Just to be sure, how do you check process state?
            As Qt is an asynchronous framework, you have give QProcess the ability to update his states, means the thread event loop must not be locked.

            SPlattenS Offline
            SPlattenS Offline
            SPlatten
            wrote on last edited by
            #5

            @KroMignon , I call state on the process when a new process is added by the application. The application keeps track of the number of instances launched and check that the launched processes are still running.

            Before launching a process I check a list of existing processes, calling the state of each process.

            Kind Regards,
            Sy

            1 Reply Last reply
            0
            • KroMignonK KroMignon

              @SPlatten said in QProcess state NotRunning but it is...:

              having now replaced startDetached with start the behaviour is the same it still returns the state NotRunning when it is.

              Just to be sure, how do you check process state?
              As Qt is an asynchronous framework, you have give QProcess the ability to update his states, means the thread event loop must not be locked.

              SPlattenS Offline
              SPlattenS Offline
              SPlatten
              wrote on last edited by SPlatten
              #6

              @KroMignon , i've just implemented a connection to the stateChanged signal and what I'm seeing is that the state is intially 2 QProcess::Running on first signal then changes almost instantly to 0 QProcess::NotRunning, yet the process is still running.

              Interestingly, I have added another process to test, which is gcalctool a calculator and this doesn't exhibit the same problem the state is 2 and remains 2, its only gedit that shows up this issue.

              Kind Regards,
              Sy

              KroMignonK 1 Reply Last reply
              0
              • SPlattenS SPlatten

                @KroMignon , i've just implemented a connection to the stateChanged signal and what I'm seeing is that the state is intially 2 QProcess::Running on first signal then changes almost instantly to 0 QProcess::NotRunning, yet the process is still running.

                Interestingly, I have added another process to test, which is gcalctool a calculator and this doesn't exhibit the same problem the state is 2 and remains 2, its only gedit that shows up this issue.

                KroMignonK Offline
                KroMignonK Offline
                KroMignon
                wrote on last edited by KroMignon
                #7

                @SPlatten said in QProcess state NotRunning but it is...:

                Interestingly, I have added another process to test, which is gcalctool a calculator and this doesn't exhibit the same problem the state is 2 and remains 2, its only gedit that shows up this issue.

                Okay, now I understand your problem.
                If you want to have multiple gedit running instances, you have to start gedit with -s or --standalone, or you will just open a new tab in current gedit instance.
                Has nothing to do with QProcess ;)

                It is an old maxim of mine that when you have excluded the impossible, whatever remains, however improbable, must be the truth. (Sherlock Holmes)

                SPlattenS 1 Reply Last reply
                1
                • KroMignonK KroMignon

                  @SPlatten said in QProcess state NotRunning but it is...:

                  Interestingly, I have added another process to test, which is gcalctool a calculator and this doesn't exhibit the same problem the state is 2 and remains 2, its only gedit that shows up this issue.

                  Okay, now I understand your problem.
                  If you want to have multiple gedit running instances, you have to start gedit with -s or --standalone, or you will just open a new tab in current gedit instance.
                  Has nothing to do with QProcess ;)

                  SPlattenS Offline
                  SPlattenS Offline
                  SPlatten
                  wrote on last edited by SPlatten
                  #8

                  @KroMignon , thank you, that makes sense, again, typical that I choose and application to test that exhibits this behavour.

                  [edit] just checked the version of gedit I'm using doesn't have that switch, its version 2.30.4 running on:

                  Linux 3.10.37-finx-rt12-generic
                  

                  Kind Regards,
                  Sy

                  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