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, detect if process is already running?
Forum Updated to NodeBB v4.3 + New Features

QProcess, detect if process is already running?

Scheduled Pinned Locked Moved Unsolved General and Desktop
9 Posts 4 Posters 2.2k 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.
  • SPlattenS Offline
    SPlattenS Offline
    SPlatten
    wrote on last edited by
    #1

    Is there a way to check if a process is already running by looking up its name or path and if so can I get the PID of it?

    I've searched for a solution and the results seem a bit vague.

    Kind Regards,
    Sy

    jsulmJ 1 Reply Last reply
    0
    • SPlattenS SPlatten

      Is there a way to check if a process is already running by looking up its name or path and if so can I get the PID of it?

      I've searched for a solution and the results seem a bit vague.

      jsulmJ Offline
      jsulmJ Offline
      jsulm
      Lifetime Qt Champion
      wrote on last edited by
      #2

      @SPlatten Not in Qt. I think you will need to use platform specific APIs or call command line tools like "ps" on Linux.

      https://forum.qt.io/topic/113070/qt-code-of-conduct

      SPlattenS 2 Replies Last reply
      1
      • jsulmJ jsulm

        @SPlatten Not in Qt. I think you will need to use platform specific APIs or call command line tools like "ps" on Linux.

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

        @jsulm , thank you, I've done this before not using Qt, I'll do the same again.

        Kind Regards,
        Sy

        1 Reply Last reply
        0
        • jsulmJ jsulm

          @SPlatten Not in Qt. I think you will need to use platform specific APIs or call command line tools like "ps" on Linux.

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

          @jsulm , what would it take to prompt Qt to explorer this and implement a solution? It strikes me this is a gapping hole in the whole multi-platform solution as you say Qt doesn't currently support it, which means unfortunately that having in order to implement a multi-platform solution I need to resort to different solutions for each platform.

          Kind Regards,
          Sy

          jsulmJ 1 Reply Last reply
          0
          • SPlattenS SPlatten

            @jsulm , what would it take to prompt Qt to explorer this and implement a solution? It strikes me this is a gapping hole in the whole multi-platform solution as you say Qt doesn't currently support it, which means unfortunately that having in order to implement a multi-platform solution I need to resort to different solutions for each platform.

            jsulmJ Offline
            jsulmJ Offline
            jsulm
            Lifetime Qt Champion
            wrote on last edited by
            #5

            @SPlatten said in QProcess, detect if process is already running?:

            what would it take to prompt Qt to explorer this and implement a solution?

            This is something you need to ask actual Qt developers as this is user forum. You can even file change request in Qt bug tracker. Checking whether there is a process executing a specific executable is a rare use case, so I doubt it has a high priority.

            https://forum.qt.io/topic/113070/qt-code-of-conduct

            SPlattenS 1 Reply Last reply
            1
            • jsulmJ jsulm

              @SPlatten said in QProcess, detect if process is already running?:

              what would it take to prompt Qt to explorer this and implement a solution?

              This is something you need to ask actual Qt developers as this is user forum. You can even file change request in Qt bug tracker. Checking whether there is a process executing a specific executable is a rare use case, so I doubt it has a high priority.

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

              @jsulm, thank you, I will do that now. The implementation I wrote was in Java.

              Kind Regards,
              Sy

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

                FYI, in the source code of Qt installer framework, there's a KD Tools Library with a runningProcesses() function which may be helpful.
                https://code.qt.io/cgit/installer-framework/installer-framework.git/tree/src/libs/kdtools/sysinfo.h#n78
                It has implementations for different platforms in:
                https://code.qt.io/cgit/installer-framework/installer-framework.git/tree/src/libs/kdtools/sysinfo_mac.cpp#n78
                https://code.qt.io/cgit/installer-framework/installer-framework.git/tree/src/libs/kdtools/sysinfo_x11.cpp#n122
                https://code.qt.io/cgit/installer-framework/installer-framework.git/tree/src/libs/kdtools/kdsysinfo_win.cpp#n59

                A 1 Reply Last reply
                8
                • SPlattenS Offline
                  SPlattenS Offline
                  SPlatten
                  wrote on last edited by
                  #8

                  @Bonnie , thank you, I will take a look now.

                  Kind Regards,
                  Sy

                  1 Reply Last reply
                  0
                  • B Bonnie

                    FYI, in the source code of Qt installer framework, there's a KD Tools Library with a runningProcesses() function which may be helpful.
                    https://code.qt.io/cgit/installer-framework/installer-framework.git/tree/src/libs/kdtools/sysinfo.h#n78
                    It has implementations for different platforms in:
                    https://code.qt.io/cgit/installer-framework/installer-framework.git/tree/src/libs/kdtools/sysinfo_mac.cpp#n78
                    https://code.qt.io/cgit/installer-framework/installer-framework.git/tree/src/libs/kdtools/sysinfo_x11.cpp#n122
                    https://code.qt.io/cgit/installer-framework/installer-framework.git/tree/src/libs/kdtools/kdsysinfo_win.cpp#n59

                    A Offline
                    A Offline
                    aliks-os
                    wrote on last edited by
                    #9

                    @Bonnie Thanks, this is just what I was looking for!

                    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