QProcess dbus service
-
I am trying to launch a dbus service file (this service file can not be in PATH! similar to a desktop entry it has an EXEC= line)
and than start another QProcess that requires the dbus service to be already running.
(I can not check if the dbus service is registered as the path and interface are unknown at that time).My question is how to do that in the best way possible?
waitForReadyRead(-1) / waitForBytesWritten(-1) return too early and the QProcess fails to start.
Adding a delay waitForFinished(2000) works but adds 2sec delay.EDIT: If it's doable to do so with glib though I haven't found a good solution with it either I can use glib in this Qt project.
-
I am trying to launch a dbus service file (this service file can not be in PATH! similar to a desktop entry it has an EXEC= line)
and than start another QProcess that requires the dbus service to be already running.
(I can not check if the dbus service is registered as the path and interface are unknown at that time).My question is how to do that in the best way possible?
waitForReadyRead(-1) / waitForBytesWritten(-1) return too early and the QProcess fails to start.
Adding a delay waitForFinished(2000) works but adds 2sec delay.EDIT: If it's doable to do so with glib though I haven't found a good solution with it either I can use glib in this Qt project.
@damianatorrpm
It seems you are saying you do need to wait for a delay, but 2 seconds is uncomfortably long. So can you either make the delay small and keep retrying in loop till it succeeds it "connecting" or whatever you are doing, or is there something in the system you can check which indicates the service is ready to connect to? Qt/QProcess
isn't magic, you have to do whatever to guide it to what you want. -
@damianatorrpm
It seems you are saying you do need to wait for a delay, but 2 seconds is uncomfortably long. So can you either make the delay small and keep retrying in loop till it succeeds it "connecting" or whatever you are doing, or is there something in the system you can check which indicates the service is ready to connect to? Qt/QProcess
isn't magic, you have to do whatever to guide it to what you want.@JonB I was hoping for some magic like waitForProcessStartedUp() or something similar
that indicates not that the process has spawned but that its initial state is ready. -
@damianatorrpm said in QProcess dbus service:
that its initial state is ready.
And who defines what 'initial state is ready' is? How should this work in a generic way?
-
@JonB I was hoping for some magic like waitForProcessStartedUp() or something similar
that indicates not that the process has spawned but that its initial state is ready.@damianatorrpm
As @Christian-Ehrlicher has said, there is no "initial state is ready". I don't know what "dbus" is, but if you say "service" perhaps, for example, the client you want to spawn is waiting for a socket to be listened on? In which you'd have to do the check for the socket to be active.If you can't do something like that, you'll probably have to either wait a "long" time like now (still unreliable), or spawn a number of attempts at short delay apart till one succeeds.