Qt DBus unable to detect an exit status of zero
-
Hi Qt community,
I would like to ask for your help.
I am developing a system using Qt Dbus.
It was able to launch dbus-daemon's session bus and launch the specific service on demand.
Problem:
The problem is when the service exits as zero, it will wait until the QDBusPendingCall timeout is exhausted and will report a false positive error:
"Failed to activate service 'com.example.foo': timed out.Other non-zero exit codes will be returned immediately (not waiting for the pending call timeout) and will be reported as:
"Process com.example.foo exited with status 1"Goal:
I wanted to trap a success (zero) exit code for the service activated without waiting for the timeout.Any suggestions is really appreciated.
Set-up:
OS: Widows 7 64 bit.
Qt toolkit: Qt 5.5.1 MSVC2013 64 bitI look forward to your response.
Sincerely,
JosephDP -
Hi and welcome to devnet,
I'm not sure I'm following you. Do you mean that you have this problem if the dbus-daemon exits normally ?
-
Hi @SGaist,
Thank you for your response and for the warm welcome.
There's no problem with dbus-daemon since it will never exit and is always running.
The problem is with the services launched and when it exits normally (exit code: 0).
P.S. all services are running on the session bus
-
To be sure I understand correctly: you are doing a call to your service that results in it exiting normally but then you get a timeout error, right ?
-
Hi @kshegunov, @SGaist,
My service exits with a exit code of 0 if successful and non-zero for error.
The problem is QT DBus can't understand perhaps an exit code of 0 which means success?
Please see minimal snippet:
QDBusConnection session = QDBusConnection::sessionBus (); QDBusMessage msg = QDBusMessage::createMethodCall ("com.myservice.foo", "/com/myservice/foo", "com.myservice.foo", "mymethod"); QDBusPendingCall call = session.asyncCall (msg, 120000); QDBusPendingCallWatcher * watcher = new QDBusPendingCallWatcher (call); QObject::connect(watcher, SIGNAL (finished(QDBusPendingCallWatcher*)), this, SLOT (onMethodFinished(QDBusPendingCallWatcher*)));
and for the onMethodFinished ():
QDBusPendingCall reply = * call; if (reply.isError()) { QString text = reply.reply().errorMessage(); qDebug () << __FUNCTION__ << "Error: " << text; } else { qDebug () << __FUNCTION__ << "OK"; } call->deleteLater();
-
Hi @kshegunov
Basically it will just return 0 on success and 1 on failure.
mymethod () { bool rc = do_something (); if (rc) { // success return 0; } else { // failure return 1; } }
-
Hi @kshegunov
Basically this is the final sequence of the app.
It is able to return immediately if the app returns a non-zero value (which in this case is 1).
However, if it will return a zero value (success in this case), the caller will wait for the timeout set (120000) and will inform a false negative result (that "Failed to activate service 'com.myservice.foo': timed out.)