Detect application running or not. How?
-
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?
-
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?
@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.
-
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?
@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 instanceOn Mac/Linux the shared memory instance may not be cleaned up correctly should the application crash. That is no problem on Windows however
-
@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 instanceOn Mac/Linux the shared memory instance may not be cleaned up correctly should the application crash. That is no problem on Windows however