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. Detect application running or not. How?
Forum Updated to NodeBB v4.3 + New Features

Detect application running or not. How?

Scheduled Pinned Locked Moved Unsolved General and Desktop
4 Posts 3 Posters 499 Views
  • 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.
  • B Offline
    B Offline
    bogong
    wrote on last edited by
    #1

    Hello!

    The application that is developing by me now, contain 2 parts. One - controller, second -Service. Controller starting Service. Both of them written on Qt. The question is how to detect from Controller is Service started or not? Is there any solution for it that is Ok for Windows, Linux and MacOS?

    JonBJ J.HilkJ 2 Replies Last reply
    0
    • B bogong

      Hello!

      The application that is developing by me now, contain 2 parts. One - controller, second -Service. Controller starting Service. Both of them written on Qt. The question is how to detect from Controller is Service started or not? Is there any solution for it that is Ok for Windows, Linux and MacOS?

      JonBJ Online
      JonBJ Online
      JonB
      wrote on last edited by
      #2

      @bogong
      If by "Service" you mean something specific, like a Windows Service or a Linux Demon, then this is platform-specific and there won't be a cross-platform way.

      If you mean that Controller uses QProcess to start Service then you can use that to check whether Service started, and probably whether it is still running.

      If they are both Qt application you could (probably) use Qt Remote Objects to test, but that means extra coding.

      Otherwise either connect them by sockets so they can test each other or if you have the PID of Service you can see whether that is still running.

      To get a (Qt) solution which works for Windows, Linux and MacOS you would have to be specific about your case/what you are looking for.

      1 Reply Last reply
      0
      • B bogong

        Hello!

        The application that is developing by me now, contain 2 parts. One - controller, second -Service. Controller starting Service. Both of them written on Qt. The question is how to detect from Controller is Service started or not? Is there any solution for it that is Ok for Windows, Linux and MacOS?

        J.HilkJ Offline
        J.HilkJ Offline
        J.Hilk
        Moderators
        wrote on last edited by J.Hilk
        #3

        @bogong I do it via QSharedMemory.
        When the app is launched it tries to attach to a SharedMemory if that is successful, than an other instance if this application is already running -> close this instance.
        If the attach fails, continue boot up and create the shared memory instance

        On Mac/Linux the shared memory instance may not be cleaned up correctly should the application crash. That is no problem on Windows however


        Be aware of the Qt Code of Conduct, when posting : https://forum.qt.io/topic/113070/qt-code-of-conduct


        Q: What's that?
        A: It's blue light.
        Q: What does it do?
        A: It turns blue.

        B 1 Reply Last reply
        2
        • J.HilkJ J.Hilk

          @bogong I do it via QSharedMemory.
          When the app is launched it tries to attach to a SharedMemory if that is successful, than an other instance if this application is already running -> close this instance.
          If the attach fails, continue boot up and create the shared memory instance

          On Mac/Linux the shared memory instance may not be cleaned up correctly should the application crash. That is no problem on Windows however

          B Offline
          B Offline
          bogong
          wrote on last edited by
          #4

          @J-Hilk Thx. Will try it out today or tomorrow.

          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